# How to allocate badge when user joins group

**URL:** https://meta.discourse.org/t/how-to-allocate-badge-when-user-joins-group/117770
**Category:** Support
**Created:** [May 15, 2019, 5:58am UTC](https://meta.discourse.org/t/how-to-allocate-badge-when-user-joins-group/117770 "2019-05-15T05:58:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Chaboi\_3000](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chaboi_3000/32/163015_2.png) [@Chaboi\_3000](https://meta.discourse.org/u/Chaboi_3000)
#### Post date: [May 15, 2019, 8:12am UTC](https://meta.discourse.org/t/how-to-allocate-badge-when-user-joins-group/117770/2 "2019-05-15T08:12:01Z")

</div>

First enable SQL on your site by doing:

```plaintext
./launcher enter app
rails c
> SiteSetting.enable_badge_sql = true

```

Then read @sam’s guide below and follow the code:

> [@Grant a badge for all members of a group](https://meta.discourse.org/t/automatically-grant-a-badge-for-all-members-of-a-group/18147):
>
> I just created a badge for all the awesome [plugin authors](https://meta.discourse.org/badges). Creating a badge targeting a group is quite easy, just type this into the SQL box: select user\_id, created\_at granted\_at, NULL post\_id from group\_users where group\_id = ( select g.id from groups g where g.name = 'GROUP\_NAME\_IN\_LOWER\_HERE' ) I will add a trigger for this at some point so granting is faster, in the mean time just go to /sidekiq/scheduler and kick off the badge job to rush it. See [Triggered custom badge queries](https://meta.discourse.org/t/triggered-custom-badge-queries/19336) for mo…

---

_[View the full topic](https://meta.discourse.org/t/how-to-allocate-badge-when-user-joins-group/117770)._
