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

Add users with specific email to group Edited

Hi guys,

I'm searching for a solution that gives me the opportunity to add users with a certain e-mail adress to an additional group.

At the moment every logged in user is added to an internal confluence group. Some users with a specific e-mail "" should be added to an additional group.

The only option i found at the moment would be a groovy script which would do that after the user is created. Or is there an easier way to do that?

I checked all groovy scripts for confluence i could and tried to add them to my needs. Actually it would only need a check for all users with the defined email adress.

import com.atlassian.confluence.user.UserAccessor
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.user.GroupManager
import com.atlassian.user.UserManager

def groupManager = ComponentLocator.getComponent(GroupManager)
def userAccessor = ComponentLocator.getComponent(UserAccessor)

def specialGroup = groupManager.getGroup("special") ?: groupManager.createGroup("special")

def users = userManager.users

def usersToMove = ["anuser", "u100"]

usersToMove.each { username ->

def user = userAccessor.getUserByName(username)

if (user) { "Add user ${} to the group: 'Special Group'"
groupManager.addMembership(specialGroup, user)


1 answer

0 votes

Hi @Andre ,

Groovy script you have suggested seems a valid option based on your needs, if not the only one without modifying data from the database directly.

I would invite you to comment on - Provide REST API methods to manage users and groups, as this could bring different ways manipulating users and groups without the need of a 3rd party plugin.

Kind regards,

i finalized the groovy script and defined a event listener so that the script starts when a new user is created.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

327 views 9 7
Join discussion

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