How to allocate badge when user joins group

I would like to assign badge to user when they join group. How to do that?

First enable SQL on your site by doing:

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

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


Thank you, will try this.

I feel it will be easy if they implement this feature in admin panel.