Retrieving list of users in group macro
Asked by Kyle Crowley:

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.


Answers:
author: David at David Simpson Apps
body: 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.

comments: author: Kyle Crowley
body: 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.


author: David at David Simpson Apps
body: Hey @Kyle Crowley,

This was copied wholesale from here:  
[](http://davidsimpson.me/2014/04/24/list-users-atlassian-confluence-user-macro/)<http://davidsimpson.me/2014/04/24/list-users-atlassian-confluence-user-macro/>

The comments came through too.


author: Kyle Crowley
body: 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.

comments: author: Alok Juneja
body: [@David at David Simpson Apps](/t5/user/viewprofilepage/user-id/781462)Has 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.