Adding users to groups through custom field automation

I noticed some mistakes in the documentation:

Actually, user fields are located in the community section of the admin sidebar.

Automation is implemented as a plugin, so you will find it under Plugins rather then under Customize.

In general, the screenshots and the navigation seem a little outdated. Also, the common term seems to be “custom user field,” and this guide often uses “user custom field” instead.

Some time ago, I suggested an alternative version that reflects most of these points. I’m sharing it here now so it can help someone in case they’re struggling with these aspects.

My draft

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

:person_raising_hand: Required user level: Administrator

Summary

  1. Set up a custom user field
  2. Create the necessary groups
  3. Create an automation to add users to groups
  4. Test the setup

Setting up the custom user field

First, create a custom user field that users will select from:
(There is also a detailed guide on user fields)

  1. Go to your site’s Admin area
  2. Navigate to User fields using the link in the community section of the admin sidebar or by visiting /admin/config/user-fields
  3. Click “Add user field”
  4. Set up the field with appropriate options

Here’s an example of how your user field might look:

:information_source: The automation assigns users to a group if their input in the custom field exactly matches a group’s full name. To ensure accuracy, use a dropdown with predefined options that match group names exactly. Free text fields can cause mismatches. If using a confirmation field, groups need to be named ‘true’ or ‘false’.

Creating the groups

Next, create the groups you want users to be automatically added to:
(There is also a detailed guide on creating groups)

  1. Go to Groups by using the link in the admin sidebar or adding /g or /groups to your forum’s URL.
  2. Click “New Group” for each group you want to create
  3. 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 it exactly matches the input in the custom user field.

Creating the automation

Now, set up the automation to add users to groups based on their custom user field selection:

  1. Go to your site’s Admin area
  2. Navigate to Plugins > Automation
  3. Click “Add automation”
  4. Select “Add user to group through User Custom Field” as the script
  5. Add a name
  6. Choose a trigger:
    • “User first logged in” to add users to groups at signup
    • “Recurring” to run on a schedule, allowing users to change groups over time
  7. Choose your user custom field from the dropdown menu
  8. Don’t forget to enable your automation

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

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 custom user field you created
  3. Complete the signup or profile update process

Here’s an example of how the user 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 custom user 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.

Q: Can I use more than one automation based on a confirmation fields?
A: Yes! While both groups’ full names must be ‘true’ or ‘false’, you can create multiple groups with different names to distinguish them. When setting up the automation, simply select the respective custom field for each one.

Additional resources

If I updated the documentation now, I would also add that there are issues when using a multi-select custom user field

1 Like