A user reports a mismatch between a member’s displayed title and the group they are linked to in Discourse, despite having only one group membership after leaving others. The issue arises because the title is not updated when the primary group changes, and the title links to the primary group instead of the one that set the title. The discussion reveals that Discourse’s logic for setting titles and primary groups is inconsistent, with no automatic update when a user leaves a group that grants a title. Contributors suggest fixes, including syncing the title with the primary group and automatically assigning a new title when one is removed. Two pull requests were submitted to address these issues: one to keep the title in sync when the primary group changes, and another to automatically grant a new title when a user leaves a group. A minor edge case was identified and fixed, ensuring the title correctly reflects the user’s current primary group when multiple groups could set titles. alxpck, codinghorror, jomaxro, sam, xrav3nz, david, and xrav3nz contributed to the discussion.
We use groups in our Discourse to organize students into small study groups. The groups are open and students join or don’t join at their discretion. We tell them to only join one group, but we’ve got an edge case where a student joined 10.
Right, but once the user leaves the extra groups, he’s only in 1 group. Should Discourse update the title at that time to match the settings from the (only) group the user’s in?
I’d say this is a bit of an edge case, not really sure. The root problem seems to be “don’t join 10 groups when you’re only supposed to join one?”
I don’t know if Discourse can enforce the fact that users are only ‘allowed’ to join one of the open groups. There would need to be a group membership quota limit somewhere?
Definitely retained, but what you see in the screenshots is still current.
My guess is he joined all the groups in alphabetical order. Baboon first so it was set as his primary group. Then the others. Then whale last so it was the last to be applied as the title.
But why does that title link to the primary group instead of the group that set the title?
There is no “on group removal do X” logic, only “on group add do X”. If you add a new group that’s primary, it sets the title – but removing a group doesn’t take any action.
The deeper fix is to enforce a group quota so you can only be a member of X groups, but I’m not sure how many other Discourse instances would need that.
If it comes up again, let us know. I generally don’t like to take actions, particularly actions that involve significant engineering time, based on a single data point.
If you change the default title on a group then all the users with the old title get a new title (Good ™)
If you add a title to a group then all users with blank titles will get the title (Good ™)
If a user is removed from a group that grants title, title is revoked if it matches (Good ™)
If a user is added to a group and has no title, we will grant a title (Good ™)
What we have that is inconsistent and confusing is:
If a user is added to a group that has primary group set we will unconditionally set primary group, regardless of what it was previously. This deviates from the “title” behavior.
If a group is saved and you “flick” primary group on, off, on. Primary group will be set unconditionally for ALL users regardless of what it was before.
If you remove membership from one group and 2 groups grant a title, we will blank out your title, but NOT set it to the other title.
Due to this inconsistency and confusion, for your use case you have to:
Ensure user is only in one group that has “primary group” set
Edit that group, set title to gibberish, save, then change it back… save.
Clearly this is all a bit crazy.
So what we should do here is:
If we strip title, we should check if there is a new title we can grant you.
We should always prefer title to match you current primary group if it grants a title. (So if we have 5 titles to pick from and your title is set to one of the 5 we should pick the right title and not override a custom one)
Those 2 fixes will HEAVILY reduce all the confusion around this. The underlying problem is that there is a relationship between auto title for group and primary group that is not properly captured in code.
Also UI wise it is “Default title” is on one screen, “Automatically set as primary group” is on another screen, this is far from ideal cause these two features are related, also the copy should explain how they are related. (Clicking on the title will take you to primary group if primary group is set)
I fear I may have confused the issue by trying to be “helpful” with all the context about multiple groups. The issue we’re trying to solve for is the mismatch between the title and where it links.
Sure, these seem like better fixes to me. I just want to treat the actual disease, not the symptoms. Treating symptoms isn’t a good use of our engineering time. Cure the disease – including better UI hints in groups, last time I checked our groups admin UI is extremely poor.