# Automatically add users to group based on part of email domain

**URL:** <https://meta.discourse.org/t/automatically-add-users-to-group-based-on-part-of-email-domain/211166>\
**Category:** Product Support\
**Created:** [December 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:** 1\
**Showing post:** 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:** [December 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.

---

_[View the full topic](https://meta.discourse.org/t/automatically-add-users-to-group-based-on-part-of-email-domain/211166)._
