# הוסף משתמשים לקבוצה באופן אוטומטי על סמך חלק מדומיין האימייל

**URL:** https://meta.discourse.org/t/automatically-add-users-to-group-based-on-part-of-email-domain/211166
**Category:** Support
**Created:** [5 בדצמבר,‏ 2021,‏ 9:05pm UTC](https://meta.discourse.org/t/automatically-add-users-to-group-based-on-part-of-email-domain/211166 "2021-12-05T21:05:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [5 בדצמבר,‏ 2021,‏ 9:05pm UTC](https://meta.discourse.org/t/automatically-add-users-to-group-based-on-part-of-email-domain/211166/1 "2021-12-05T21:05:18Z")

</div>

I’d like automatically to add all users with [name@subdomain1.example.com](mailto:name@subdomain1.example.com) (or [name@subdomain2.example.com](mailto:name@subdomain2.example.com) or [name@subdomain3.example.com](mailto:name@subdomain3.example.com)) but unfortunately if I type [example.com](http://example.com) it doesn’t add any of them to the group. Is there a way round it?

The closest I found in old topics here were these two posts from 2018 and 2020 respectively:

> [@Exclude certain email sub-domains from automatic group membership](https://meta.discourse.org/t/exclude-certain-email-sub-domains-from-automatic-group-membership/86212/6):
>
> Sure, I think a PR that adds support for wildcards would be fine. Search for automatic\_membership\_email\_domains in the code if you want to give this a try. It’s used in a couple of files.

> [@Automatic registration domain wild card](https://meta.discourse.org/t/automatic-registration-domain-wild-card/146933/3):
>
> Yeah there is an inconsistency internally, our automatic group membership is based off a strict domain match per: Our matcher for the email\_domains\_whitelist uses this match I think it makes sense to make this coherent and consistent. @techAPJ can you adjust the group regex.. carefully and make sure it is tested so it also allows subdomains.

It looks like the plan was to allow [example.com](http://example.com) to include all its subdomains for automatic group membership.

Thanks.

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [10 בדצמבר,‏ 2021,‏ 9:13pm UTC](https://meta.discourse.org/t/automatically-add-users-to-group-based-on-part-of-email-domain/211166/2 "2021-12-10T21:13:16Z")

</div>

Is there any way of making this work? I’d like to type “[example.com](http://example.com)” and have it include not only “@example.com” but also “@sub1.example.com”, “@sub2.example.com” etc. Thanks.

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [17 בדצמבר,‏ 2021,‏ 7:13am UTC](https://meta.discourse.org/t/automatically-add-users-to-group-based-on-part-of-email-domain/211166/3 "2021-12-17T07:13:19Z")

</div>

This is quite important for me as two of the domains (government ones) each have dozens or maybe hundreds of subdomains and it wouldn’t be feasible to keep track of them manually.

One of the posts quoted above ends with the following sentence, which makes me hopeful:

> [@Automatic registration domain wild card](https://meta.discourse.org/t/automatic-registration-domain-wild-card/146933/3):
>
> @techAPJ can you adjust the group regex… carefully and make sure it is tested so it also allows subdomains.
