# Group membership scripting

**URL:** <https://meta.discourse.org/t/group-membership-scripting/226473>\
**Category:** Product Support\
**Created:** [May 8, 2022, 7:46pm UTC](https://meta.discourse.org/t/group-membership-scripting/226473 "2022-05-08T19:46:31Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![carmiac](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carmiac/32/77923_2.png) [@carmiac](https://meta.discourse.org/u/carmiac)\
**Post date:** [May 8, 2022, 7:46pm UTC](https://meta.discourse.org/t/group-membership-scripting/226473/1 "2022-05-08T19:46:31Z")

</div>

I’m the admin for a organization’s forum with several levels of membership, which correspond to custom group membership in the forum. Currently this requires a manual process for every new member where I get the new members email address, check to see if that is associated with a user account and then add them to the custom group.

What I would like is a script that would take a list of email addresses, and if there is a user with that address add them to a group and if not send out an invite with the group permission already added. How would I write a script like that?

Thanks!

EDIT:

Example from below:  
I have these three email address:  
[alice@example.com](mailto:alice@example.com) - Belongs to a forum member who is not a group member of SomeGroup  
[bob@foo.org](mailto:bob@foo.org) - Belongs to a forum member who is a member of SomeGroup  
[carol@bar.edu](mailto:carol@bar.edu) - Does not belong to a forum member.

I’d like to add the user associated with [alice@example.com](mailto:alice@example.com) to SomeGroup (and send a welcome message), do nothing for the user [bob@foo.org](mailto:bob@foo.org), and send a forum invite with the group enrollment flag to [carol@bar.edu](mailto:carol@bar.edu).

---

_[View the full topic](https://meta.discourse.org/t/group-membership-scripting/226473)._
