User List by Email Filter — Confluence Cloud Macro
The macro retrieves all Confluence groups and iterates through them to gather members. It checks each member's email against a specified filter, storing matching email addresses and corresponding display names in a map. If matches are found, it presents the results in a table format.
User Parameters
Email filter
Select an email for filtering
Template
## Fetch groups
#set($groups = $ConfluenceManager.get("/wiki/rest/api/group"))
## Check if there are any groups available
#if ($groups && $groups.results.size() > 0)
#set($uniqueEmails = {}) ## A map to store unique email addresses and corresponding user names
## Loop through each group to retrieve group members
#foreach($group in $groups.results)
#set($groupMembers = $ConfluenceManager.get("/wiki/rest/api/group/$group.id/membersByGroupId"))
## Loop through each member in the group
#foreach($member in $groupMembers.results)
## Check if the email matches the filter and is not already in the uniqueEmails map
#if ($StringUtils.contains($member.email, $parameters.emailFilter) && !$uniqueEmails.containsKey($member.email))
#set($discard = $uniqueEmails.put($member.email, $member))
#end
#end
#end
## If no matches are found, show a message indicating no matching email addresses
#if ($uniqueEmails.size() == 0)
<p>
No email addresses match the filter: <strong>$parameters.emailFilter</strong>
</p>
#break
#end
## If there are matching email addresses, display them in a table
#if ($uniqueEmails.size() > 0)
<table class="aui aui-table-interactive aui-table-rowhover" style="width: fit-content;">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
## Loop through the uniqueEmails map to display each entry
#foreach($entry in $uniqueEmails.entrySet())
<tr>
<td><a href="${baseUrl}/people/${entry.value.accountId}" target="_blank">$entry.value.displayName</a></td>
<td><a href="mailto:$entry.key">$entry.key</a></td>
</tr>
#end
</tbody>
</table>
#end
#endRecommended Macros
User macro for displaying issues using custom JQL filter
Display the top comments from a selected Confluence page or the current page by default.
This macro allows user to retrieve all pages from current space despite limitation of 250 pages per request
Read and display the fixed version of Confluence pages by checking page or ancestor labels
Macro that will show a "Delete me" message only for editors (in the Page Edit mode)
Filter Confluence groups based on a specified filter value and display the results in different formats.
Find image within page attachments. Handy for reuse files and update them all at once
Display a list of Confluence pages with CSV download feature