[CONFLUENCE] Is there a user macro which will print out a list of groups the current user is assigned to?

Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2013

I seem to have a lot of user macros that will search for different user information but one I am sorely missing is one that will print out a list of groups a user is in, specifically the current user. Would someone mind providing me with one as I am scratching my head at this one?

Thank you

2 answers

1 accepted

3 votes
Answer accepted
Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2013

If anybody is interested, a very simple macro to print out a bulleted list of every group the current user is part of can be made with the following:

## @noparams

#set ($groups = $userAccessor.getGroupNamesForUserName($action.remoteUser.name))
<ul>
	#foreach ($group in $groups)
		<li>$group</li>
	#end
</ul>

3 votes
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2013

The $userAccessor object is of type UserAccessor, and has a method called getGroupNamesForUserName(). You pass this a user name.

For the current user, this would be something like this (can't remember the exact syntax for getting current user):

$userAccessor.getGroupNamesForUserName($req.remoteUser.name)

hth,

matt

Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2013

As always, much appreciated Matthew.

You were very close, it was $userAccessor.getGroupNamesForUserName($action.remoteUser.name) - but you get the credit.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events