# Update group membership using external database

**URL:** https://meta.discourse.org/t/update-group-membership-using-external-database/166541
**Category:** Support
**Created:** [October 7, 2020, 12:55pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541 "2020-10-07T12:55:36Z")
**Posts on this page:** 7
**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: [October 7, 2020, 12:55pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541/1 "2020-10-07T12:55:36Z")

</div>

Would it be possible to create a private category usable only by a custom group and synchronise membership of that group with an external database?

I’m considering creating a category on a public forum for a mirror of a private mailing list. Not everyone on one would be on the other. For this to work, Discourse (or a separate script) would need to add and remove existing Discourse users to and from the custom group based on who is from time to time a member of the email list.

Thanks.

---

<div class="post-metadata">

### Author: ![osioke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osioke/32/238946_2.png) [@osioke](https://meta.discourse.org/u/osioke)
#### Post date: [October 7, 2020, 1:23pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541/2 "2020-10-07T13:23:18Z")

</div>

This should be possible using WordPress as the SSO provider for Discourse. You’ll have to [install and configure WordPress](https://meta.discourse.org/t/wp-discourse-plugin-installation-and-setup/50752), and see [Manage group membership in Discourse with WP Discourse SSO](https://meta.discourse.org/t/managing-discourse-group-membership-with-wp-discourse-sso/74724) for the other details.

---

<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: [October 7, 2020, 1:53pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541/3 "2020-10-07T13:53:28Z")

</div>

In that case, I would need to install Wordpress solely as a bridge between Mailman and Discourse. I am sure I could sync users between Mailman and Wordpress. But it would be a sledgehammer to crack a nut.

Are they any more direct ways?

Thanks.

---

<div class="post-metadata">

### Author: ![osioke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osioke/32/238946_2.png) [@osioke](https://meta.discourse.org/u/osioke)
#### Post date: [October 7, 2020, 1:59pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541/4 "2020-10-07T13:59:29Z")

</div>

Hmm, not sure. Maybe @simon has some ideas?

---

<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: [October 7, 2020, 3:27pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541/5 "2020-10-07T15:27:04Z")

</div>

I’ve just had a look at the Discourse API documentation page. It’s possible to get a list of users (which contains usernames), get user by username (which contains the user’s groups), add user to group, and remove user from group. I guess I could run a cron job regularly to ensure only current Mailman list subscribers are members of the Discourse private group.

Has this been done already?

---

<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: [October 7, 2020, 9:29pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541/6 "2020-10-07T21:29:00Z")

</div>

Something API solution like that is what I would recommend. I’m not aware of a mailman-to-discourse solution. If you’re running the mailman server, you could add hooks there to add/remove people from the Discourse group when their subscription status changes, but a daily cronjob that syncs them is probably easier and nearly as effective. Depending on how many subscribers and churn rate, you could also be even more low-tech and just let people request access to the group or contrive to [Invite users to a group](https://meta.discourse.org/t/invite-individual-users-to-a-group/15544).

---

<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: [November 6, 2020, 9:33pm UTC](https://meta.discourse.org/t/update-group-membership-using-external-database/166541/7 "2020-11-06T21:33:42Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
