User Macro for displaying the Profile Picture of a Group of users

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This KB shows an example of a User Macro which displays a list of Profile pictures for a Confluence group.

Solution

Be mindful that customisations are not part of our support scope as per Atlassian Support Offerings. Any effort provided to support issues related to customisation will be on a best-effort basis by the support engineer.

The following User Macro could help:

  1. Browse to General Configuration > User Macros
  2. Choose Create a User Macro
  3. In the definition of the macro use ProfileGroupPicture as macro name and the following code as Template:

    ## Macro title: ProfileGroupPicture
    ## Description: User Macro for retrieving a list of Profile Pictures based on a group name
    ## @param Group:title=Name|type=string|required=true|desc=Group 
    
    #set($group = $userAccessor.getGroup($paramGroup))
    #set($users = $userAccessor.getMembers($group))
    #foreach($user in $users)
          <a class="userLogoLink" data-username="$user.name" href="/confluence/display/~$user.name" title="" data-user-hover-bound="true">
                <img class="userLogo logo" src="$userAccessor.getUserProfilePicture($user).getUriReference()" alt="User icon: $user.name" title="">
          </a>
    #end

    You may need to adjust the context path in href tag to create a correct link to your user' details pages. 

  4. Click Save

In order to use this User Macro, just add the "Profile Group Picture" macro in your page and provide a group username. This will list an image for each user in the mentioned group: 


This macro makes use of the userAccessor context, so you should allow this module in your setenv.sh  file as explained in CONFSERVER-82741 - Getting issue details... STATUS

CATALINA_OPTS="-Dmacro.required.velocity.context.keys=userAccessor ${CATALINA_OPTS}"

To know more on User Macros, please refer the below document

Last modified on Dec 6, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.