Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom User Macro to Select Group and Display Member Profiles

Kmmaughs
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.
April 29, 2021

I'm trying to write a user macro that the user can input/select a group and the macro will render the profiles for each of the members of the group. This would allow members to float in and out of the groups without needing to manually update individual user profile macros. I've read and tried to mimic how this was done in several other community posts. This is what I've come up with so far, but it's returning an error while rendering:

 

## Users Pictures for Group - Confluence User Macro
##
## Produces a pile of user profile pictures for members of a specific group
##
## @param Group:title=Group Name|type=string|required=true|desc=The group name


#set($containerManagerClass = $action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null, null))
#set($containerContext = $containerManager.containerContext)

#set($userAccessor = $containerManager.containerContext.getComponent('userAccessor'))
#set($groupManager = $containerManager.containerContext.getComponent("groupManager"))
#set($group = $groupManager.getGroup($paramGroup))
#set($users = $userAccessor.getMemberNamesAsList($group) )

#foreach( $username in $users )

#set($confluenceUser = $userAccessor.getUserByName($username))
<ac:structured-macro ac:name="profile">
<ac:parameter ac:name="user">
<ri:user ri:userkey="$confluenceUser.key" >
</ac:parameter>
</ac:structured-macro>
#end

 

Any pointers would be appreciated. 

1 answer

0 votes
Fabian Lim
Community Champion
January 30, 2022

Hi @Kmmaughs

Have you been able to figure out a solution for this one?  I'm interested.

Thanks

Kmmaughs
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.
March 31, 2022

Unfortunately, no :( I sort of gave up on the effort, so we manually manage users profiles. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events