Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Retrieving list of users in group macro

Kyle Crowley June 18, 2014

Hi there,

I'm new to Confluence but I'm starting to get a hang of it.

Right now I have a page on a space that is for our team. I have a section where I am putting "profile picture" macros to show each member of the group.

I was wonder how I could make a macro that would loop through the members of a group and call that macro, given a group name to look at.

So here is the psuedocode:

param1 = <PASSED IN PARAM>

foreach member in param1

{

profile_picture(member)

}

So the macro would take in the group name, loop thorugh the members, and call the "profile picture" macro for each member.

I know there is a "user list" macro, but it does not have exactly what I am looking for.

Any help would be greatly appreciated.

Thank you.

2 answers

1 accepted

1 vote
Answer accepted
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 18, 2014

Try this user macro:

## Users Pictures for Group - Confluence User Macro
##
##   Produces a pile of user profile pictures for members of a specific group
##
## WARNING:
##
##   Use very sparingly as this *will* slow down large Confluence instances.
##   Yes, it will try to print out 100,000 users if you have that many in the group
##
##   I generally remove this user macro after using once and add only when needed.
##   Or enable it for admins only.
##
## @param Group:title=Group Name|type=string|required=true|desc=The group name (yes, really)

  
#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-picture">
<ac:parameter ac:name="User">
<ri:user ri:userkey="$confluenceUser.key" >
</ac:parameter&gt;&lt;/ac:structured-macro> #end

It should produce a pile of user profile pictures for members of a specific group.

Kyle Crowley June 18, 2014

Works exactly how I wanted it to. Thanks!

P.S. I understand the concern for the large sized groups. For a group like mine, it will not be as bad since we are a group of > 10 people. If you passed in something like "confluence-users" and you had a lot of people using Confluence, it might get hairy then.

In any event, thanks so much.

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 19, 2014

Hey @Kyle Crowley,

This was copied wholesale from here:
http://davidsimpson.me/2014/04/24/list-users-atlassian-confluence-user-macro/

The comments came through too.

Like InfoSec likes this
0 votes
Kyle Crowley June 18, 2014

Works exactly how I wanted it to. Thanks!

P.S. I understand the concern for the large sized groups. For a group like mine, it will not be as bad since we are a group of > 10 people. If you passed in something like "confluence-users" and you had a lot of people using Confluence, it might get hairy then.

In any event, thanks so much.

Alok Juneja April 26, 2021

@David at David Simpson AppsHas something changed in the years between that this macro is not longer working. I would really appreciate if you can guide, as this macro is going to add so much value to our confluence. Thanks for all your efforts.

Like Kmmaughs likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events