# Automatic addition of users to group based on email domain

**URL:** <https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157>\
**Category:** SSO\
**Created:** [April 7, 2020, 4:58pm UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157 "2020-04-07T16:58:15Z")\
**Posts on this page:** 8\
**Page:** 1

## AI-generated summary

The discussion revolves around an issue with automatic user group assignment based on email domain in a Discourse forum using SSO. [hollyw](/t/-/147157/1) reports that new users with a specific email domain are not being automatically added to a custom group, requiring manual intervention to update membership. [codinghorror](/t/-/147157/2) notes this is a known inconsistency, and [sam](/t/-/147157/3) identifies it as an SSO bug, particularly when `sso_overrides_email` is enabled. [sam](/t/-/147157/6) explains that the auto-group membership rule doesn't apply retroactively to users updated via SSO, only to initial creations, and suggests ensuring the "Apply the same email domain rule to add existing registered users" option is enabled, though this setting may be removed in the future. [pfaffman](/t/-/147157/7) recommends managing group assignments via SSO during login instead.

<div class="post-metadata">

**Author:** ![hollyw](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@hollyw](https://meta.discourse.org/u/hollyw)\
**Post date:** [April 7, 2020, 4:58pm UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/1 "2020-04-07T16:58:15Z")

</div>

On our forum, we created a custom group for users with a certain email domain. My understanding was that new users who join the site with this domain would automatically be added to the group. However, it doesn’t seem to be functioning in an automated fashion. Right now I have to go to Group \> Membership and click Save Changes to see the most recent wave of new users get added to this group. Otherwise they don’t seem to be added.

Is this expected behavior? I should also add that we’re using SSO, so I’m unsure whether that would impact this feature.

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [April 7, 2020, 10:41pm UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/2 "2020-04-07T22:41:24Z")

</div>

@sam this is the same as the other recent report, where these rules aren’t consistent.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [April 7, 2020, 10:45pm UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/3 "2020-04-07T22:45:19Z")

</div>

Looks like an SSO bug to me

Can you confirm you are using [Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045)

---

<div class="post-metadata">

**Author:** ![hollyw](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@hollyw](https://meta.discourse.org/u/hollyw)\
**Post date:** [April 7, 2020, 10:54pm UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/4 "2020-04-07T22:54:27Z")

</div>

Yes, we are using the official SSO for Discourse.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [April 8, 2020, 6:36am UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/6 "2020-04-08T06:36:38Z")

</div>

I think this is the bug.

When you were updating emails via SSO cause you have `sso_overrides_email` enabled the auto group membership was not taking.

It would take for initial user creations.

Note, there is the whole “retroactive” concept that is massively confusing, we should probably just remove that. I recommend you make sure `Apply the same email domain rule to add existing registered users` is always set, we are going to be removing it.

[https://github.com/discourse/discourse/commit/b824898f614d21c43a78fec30481757341106d5a](https://github.com/discourse/discourse/commit/b824898f614d21c43a78fec30481757341106d5a)

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [April 8, 2020, 2:30pm UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/7 "2020-04-08T14:30:29Z")

</div>

I would suggest that you manage those groups with sso and push them when they log in.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [May 3, 2024, 5:33am UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/8 "2024-05-03T05:33:34Z")

</div>

Automatically bumped on May 3, 2024, 5:33am UTC



---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [May 3, 2024, 8:57am UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/9 "2024-05-03T08:57:17Z")

</div>

Closed on May 3, 2024, 8:57am UTC


