Granting Manual Badges

(David Kwan) #1

Is the only way to grant manual badges to go into a user’s profile and add them? Is there a quicker way (ex: a place where you can see a list of users and click to add the same badge to more than one of them)?


There is a similar feature request that’s #pr-welcome; it’s actually been on my list of things that I want to try to implement.

Not sure about mass badge-granting though. What’s your use case here? Could groups be leveraged?

(David Kwan) #3

Thanks for the heads up! My use case is that we have a website that allows teachers to build assignments, collect live student insights (like a Google Doc), and easily track student growth. We are using Discourse primarily as a place where they can learn and collaborate together. As such, we are using the badging system to award learning and collaborative achievements as shown on our badging page ( The majority of the badges there are new since the behaviors necessary to earn them are specific to our purpose. With that, it’s going to be really inefficient if we need to click into a user profile to award a a badge manually. I am looking for a better way to do this.

You mentioned Groups. How could groups be leveraged?


Really nice custom badges you have there!

Since it’s possible to bulk add users to a group, you could then: Automatically grant a badge for all members of a group

Alternatively, if you are comfortable enough with Ruby, you could write and execute a Ruby script in your production environment, along the lines of:

# or you can lookup users by username/email
users = User.find_by(id: [1, 2, 3, ..])

# 100 is the id of the badge
badge = Badge.find(100)

users.find_each { |user| BadgeGranter.grant(badge, user) }

From a long term perspective, I think maintaining and granting badges on a regular basis will do?

(David Kwan) #5

Thanks for the kind words and ideas! I think I will probably just end up going with the Group one and creating groups for different badges and bulk adding users to those groups at the end of the day!

(Joseph Coates) #6

You could modify Sam’s bug reporter badge code.

Basically, you pick a category, and grant a badge to any user who posts a topic liked by your staff. You can then award badges as easily as hitting the like button.

You could concevably do this with a different badge for every category on your site.

(Joseph Coates) #8

They can have a category for outside events where event hosts can start a topic about their events. Then staff can just like the outside event topics to grant badges. They could even tag the various kinds of events by tagging the post then have a custom SQL to grant different badges based on the topic tag.