Adding users to groups through custom field automation

:bookmark: This guide explains how to automatically add users to groups based on their selection of a user custom field during signup or profile update.

:person_raising_hand: Required user level: Administrator

Summary

  1. Create the necessary groups
  2. Set up a User Custom Field
  3. Create an automation to add users to groups
  4. Test the setup

Creating the groups

First, create the groups you want users to be automatically added to:

  1. Go to your site’s Admin area
  2. Navigate to Users > Groups
  3. Click “New Group” for each group you want to create
  4. Make sure to add a “Full Name” for each group, as the automation script uses this

:information_source: The automation script uses a group’s Full Name, so ensure you add one for each group.

Setting up the User Custom Field

Next, create a User Custom Field that users will select from:

  1. Go to your site’s Admin area
  2. Navigate to Users > User Fields
  3. Click “New User Field”
  4. Set up the field with appropriate options

Here’s an example of how your User Custom Field might look:

Creating the automation

Now, set up the automation to add users to groups based on their User Custom Field selection:

  1. Go to your site’s Admin area
  2. Navigate to Customize > Automations
  3. Click “New Automation”
  4. Choose a trigger:
    • “When a user first logs in” to add users to groups at signup
    • “Recurring” to run on a schedule, allowing users to change groups over time
  5. Select “Add user to group through custom field” as the action
  6. Choose your User Custom Field from the dropdown menu
  7. Configure the automation settings

Here’s an example of how your automation setup might look:

:mega: The automation now includes a dropdown to select your existing User Custom Fields, making setup easier and less prone to errors.

Testing the setup

To ensure everything is working correctly:

  1. Sign up as a new user or update an existing user’s profile
  2. Select an option from the User Custom Field you created
  3. Complete the signup or profile update process

Here’s an example of how the User Custom Field might appear during signup:

After the automation runs, you should see the user added to the appropriate group:

FAQs

Q: Can this automation add users to primary groups?
A: By default, this automation adds users to secondary groups. To set a group as primary, go to the group’s Manage > Membership settings page and select “Automatically set as primary group”.

Q: How often does the automation run if I choose the “Recurring” trigger?
A: You can set the frequency when creating the automation. Choose a schedule that best fits your community’s needs.

Q: What happens if a user changes their user custom field selection?
A: If you’ve set up a recurring automation, it will update the user’s group membership based on their new selection during the next run.

Additional resources

Last edited by @hugh 2024-07-16T02:47:08Z

Last checked by @hugh 2024-07-16T02:47:13Z

Check documentPerform check on document:
13 Likes

This Automation has now been tweaked to include a dropdown to select your existing User Custom Fields from. :partying_face:

No more rooting around in the user custom field json trying to find an id number, or any awkward typos snarling things up. Just super smooth and friendly UI. :sunglasses:

7 Likes

Pls the automation can only add users to the secondary group, what should I do if I want to add him to the primary group?

I think this would be set on the group’s Manage/Membership setting page where you can select ‘Automatically set as primary group’.

2 Likes

What am I missing?

Did all of this but it is not working as expected after testing.

Do you need to match the “full name” of the group to the automation name option? i.e. I see no option to pick the group you want to the user to be added to on trigger event.

I’m missing a step or something is not clicking in my head.

2 Likes

Thanks, and so deleted all previous setups, sync name fields and tested signup. Still no success.

To confirm, you use the Group “full name” not the @name?

To add, I also changed the automation to recurring so I could trigger the automation manually and this also has not worked.

I just created everything from scratch:

  1. My custom user field “Pet team”:

  2. The new groups: Name “cat-lovers”, Full name “cat” and Name “dog-lovers”, Full name “dog”

  3. The automation: (I chose every 1 minute for fast testing)

  4. Testing

    1. Choosing “cat” for “Pet team” in my profile preferences
    2. Checking the group membership:
    3. Choosing “dog” for “Pet team” in my profile preferences
    4. Checking the group membership:
2 Likes

I was originally going to post a new topic “how to filter user signup before : after” so all new users from X day go into X group

However, I found this topic and decided it was what I needed.

The difference in my use case is to your example (thank you again) which is possibly even simpler, there is no need for multi chocie so the user only have to tick a “confirmation” :white_check_mark: and that confirmation field fix the users to X group

Also I can see the test user and the X filed = true in the user profile, so that works on signup.

AS outlined above in my case use there is only cat option and it is assigned by “confirmation” click, it is a mono filter requirement.

Maybe I’ll try force it using drop down instead and see if it works.

I also got a working automation using a confirmation custom user field.

1 Like

Ok that was it, I changed custom user field to dropdown with only one option and it worked.

I can not replicate! :grinning:

1 Like

Does this help? Maybe you can spot the difference

The user field


The automation

The group

1 Like

Your Group name is “true” ?

Yes, it must match the value of the custom user field. A confirmation field is either ‘true’ or ‘false’.

3 Likes

Ok, that is what I was thinking was going on.

It strikes me then you are then limited to one group called “true” and you can never user that “confirmation” approach again.

I will run with the drop down for now as I might want to change the group filter on say an annual basis, i.e. a group for each year.

Finally, if I can suggest to the makers of the automation, to perhaps consider a more explicit step and thus field, to specify the intended user group that is the target of your filter, as this implied part of the setup has caused me a lot of confusion and time as it probably as others.

Thank for all your help and exposé @Moin

1 Like