Setting a primary group for users

:bookmark: This guide explains the concept of “Primary Group” in Discourse, detailing what it does and how to set it up.

:person_raising_hand: Required user level: Administrator

What is a primary group?

A primary group is a custom group that can be assigned to a user as their main group affiliation. This assignment has several visual and functional implications within the Discourse platform.

Setting a primary group

To set a primary group for a user:

  1. Navigate to /admin/users
  2. Click on the specific user’s name
  3. On the user’s admin page (/admin/users/{userId}/{username}), locate the groups options
  4. Select a “Custom” group as the primary group

:information_source: You can only select a primary group for a user if they belong to “Custom” groups. Automatic groups like admins, moderators, staff, trust_level_0, etc., cannot be set as primary groups.

Effects of setting a primary group

Setting a primary group for a user has several effects:

1. Adds CSS class to user’s posts

If the primary group is called team, a CSS class group-team is added to the user’s posts. This can be used to style posts differently based on the user’s primary group.

2. Adds title to user’s profile

You can configure a title for members of a group:

  1. Go to the group’s Manage page
  2. Set a Default title

This title will appear on the user’s profile:

:information_source: Users can have multiple titles. A title awarded from a badge takes precedence over a group title, but this can be overridden in the user’s preferences.

3. Adds an avatar flair

You can configure an avatar flair for all members of a group. When the group is set as primary, this flair will appear on the user’s avatar.

How to set a primary group

There are several ways to set a primary group:

  1. From the user’s admin page at /admin/users/{userid}/{username}
  2. Enable “Automatically set as primary group” in the group’s settings
  3. Group owners can set or remove the group as primary from the group’s Members page
  4. Allow users to select their own primary group by enabling the user selected primary groups setting

:information_source: If a user is added to multiple groups that have the Automatically set as primary group setting enabled, their primary group will be the last group they joined.

Bulk removing primary groups

To remove primary groups for multiple users:

  1. Create a new group with tight restrictions (admin only) and check “set as primary group”
  2. Add all users whose primary group you want to clear to this new group
  3. Delete the new group

Additional resources

Last edited by @Moin 2024-07-16T06:08:14Z

Check documentPerform check on document:
35 Likes