Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible to read out all crowd user groups with their members via user macro?

Hello all,

is it possible to read out or output all existing crowd user groups with their corresponding members.
I have made a first attempt via

## Macro title: Listing Confluence groups
## Macro has a body: Y
## Body processing: N
## Output: Unsorted filtered list of confluence groups
##
## Developed by: xxx
## Date created: xx/xx/20xx
## Installed by: xxx
##
## Parameters
## @noparams

#set ($Count = 0)

<h1>User groups</h1>
<hr>
<ul>
#foreach($group in $userAccessor.getGroups())
  <li>$group.Name</li>
  #set ($Count = $Count + 1)
#end
</ul>
<hr>
<h6>Group count: <b>$Count</b></h6>

started.
Now I would like to replace the previous script with this

## Macro title: Show Group Membership
## Description: List all the members of a group
## Macro has a body: N
##
## Developed by: xxx
## Date created: xx/xx/20xx
## Installed by: xxx
##
## @param Group:title=Group Name|type=string|required=true|desc=Insert 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 = $userAccessor.getGroup($paramGroup))
#set($users = $userAccessor.getMemberNamesAsList($group))

<style type="text/css">
@media all {
.show-group-membership-macro .expand-control {
margin-bottom: 0px;
}
}
</style>

<span class="show-group-membership-macro">
<ac:structured-macro ac:name="expand" ac:schema-version="1">
<ac:parameter ac:name="title">$paramGroup</ac:parameter>
<ac:rich-text-body>
<ul>
#foreach( $username in $users )
#set($confluenceUser = $userAccessor.getUserByName($username))
<li><ac:link>
<ri:user ri:userkey="$confluenceUser.key" />
</ac:link></li>
#end
</ul>
</ac:rich-text-body>
</ac:structured-macro>
</span>

couple. Unfortunately I am missing the approach how to implement this.
Does anyone here have an idea or a little help.

Thanks for your help

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

39,188 views 28 126
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you