This guide explains the concept of “Primary Group” in Discourse, detailing what it does and how to set it up.
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:
- Navigate to
/admin/users
- Click on the specific user’s name
- On the user’s admin page (
/admin/users/{userId}/{username}
), locate the groups options - Select a “Custom” group as the primary group
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:
- Go to the group’s Manage page
- Set a Default title
This title will appear on the user’s profile:
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:
- From the user’s admin page at
/admin/users/{userid}/{username}
- Enable “Automatically set as primary group” in the group’s settings
- Group owners can set or remove the group as primary from the group’s Members page
- Allow users to select their own primary group by enabling the
user selected primary groups
setting
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:
- Create a new group with tight restrictions (admin only) and check “set as primary group”
- Add all users whose primary group you want to clear to this new group
- Delete the new group
Additional resources
Last edited by @Moin 2024-07-16T06:08:14Z
Check document
Perform check on document: