# Automatically add/remove users to/from a group based on badge id?

**URL:** https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431
**Category:** Feature
**Tags:** badges, groups, completed
**Created:** [25 Julho , 2015 21:24 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431 "2015-07-25T21:24:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mr8](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mr8](https://meta.discourse.org/u/mr8)
#### Post date: [25 Julho , 2015 21:24 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431/1 "2015-07-25T21:24:56Z")

</div>

Would it be possible to somehow automatically add/remove a user from a group based on a certain badge ID ( or IDs)?

e.g. - add users to **X Group** if they have have **badge\_id 12** (50 liked posts in past 60 days)?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [25 Julho , 2015 23:39 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431/2 "2015-07-25T23:39:58Z")

</div>

Groups are used for category security, and the closest thing to “50 liked posts in last 60 days” is Trust Level 3, which has an automatic group (`trust_level_3`). Does just using the TL3 lounge, which comes with your install by default, work for you?

---

<div class="post-metadata">

### Author: ![mr8](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mr8](https://meta.discourse.org/u/mr8)
#### Post date: [26 Julho , 2015 04:47 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431/3 "2015-07-26T04:47:23Z")

</div>

That was just an example, but we’d like to give our active users who post great stuff (hence the ‘last 60 days part’ which we could query via the Badge Query) special access to an extra category where we posts betas and previews.

Actually, would it be possible to grant group access via some query similar to the way we grant badges?

---

<div class="post-metadata">

### Author: ![marktheis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marktheis/32/38285_2.png) [@marktheis](https://meta.discourse.org/u/marktheis)
#### Post date: [1 Agosto , 2015 14:54 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431/4 "2015-08-01T14:54:12Z")

</div>

I’m also interested in this.. Did you find a way to do it?

---

<div class="post-metadata">

### Author: ![mr8](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mr8](https://meta.discourse.org/u/mr8)
#### Post date: [3 Agosto , 2015 18:25 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431/5 "2015-08-03T18:25:31Z")

</div>

Would really be great if this becomes a core feature since plugins seem pretty fragile with updates!

Until then, I’m thinking of maybe doing this via the api - have a script query a badge\_id (`/user_badges.json?badge_id=XX`) every few days and grant/remove users from the group (`PUT`/`DELETE` the user(s) on `/admin/groups/XX/members.json`)..

---

<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: [11 Outubro , 2023 10:34 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431/6 "2023-10-11T10:34:23Z")

</div>



---

<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: [11 Outubro , 2023 10:42 UTC](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431/7 "2023-10-11T10:42:40Z")

</div>

Isso agora é uma coisa. 🥳

> [@User Group Membership Management Through Badges](https://meta.discourse.org/t/user-group-membership-management-through-badges/281836):
>
> We recently added the update\_user\_group\_membership\_via\_badge automation. This were long standing requests at: (including one from yours truly) [Automatic membership of badge earners in the group](https://meta.discourse.org/t/automatic-membership-of-badge-earners-in-the-group/172315)[What if badges could optionally synchronize group membership?](https://meta.discourse.org/t/what-if-badges-could-optionally-synchronize-group-membership/92232)[Automatically add/remove users to/from a group based on badge id?](https://meta.discourse.org/t/automatically-add-remove-users-to-from-a-group-based-on-badge-id/31431)[Badge granting triggers group membership](https://meta.discourse.org/t/badge-granting-triggers-group-membership/143242)What does it do? This feature allows you to automate user group membership based on their badges. It provides you with the ability to…
