Get group for current user only

Using security.getUserGroups example I always get information for all users and all groups. How can I get just the group(s) for the current loged in user?

Don’t know it by heart but I believe it is the general example in the methodeditor when you select the plugin that gives you your answer. At least that’s where I got it from…

you can say:

getUserGroups(userId)

but that shouldn’t be needed because

getUserGroups()

will return an empty list with a error if the user is not logged in or if logged in then it will return the groups for the current users..

do you see something different?

You are right - I was using the example method which includes loops to get all user groups ids and names etc. as I was interested in also getting the group names.

security.getUserGroups() does indeed just get the group ids for the current user.