What are Badges?

(Erlend Sogge Heggen) #1

Badges in Discourse reinforce positive user behaviour and facilitates “learning by doing”. It is a central part of Discourse’s gamification features.

Receiving Badges

There are two ways to receive a badge:

  1. Manually granted by an administrative user
  2. Automatically granted by the system

Furthermore, all badges have some optional properties.

  • Allow badge to be used as a title
  • Can be granted multiple times
  • Show badge on the public badges page
  • Show post granting badge on badge page

Creating Badges

Manual and automatic badges are created the same way, via the admin panel. What sets them apart is how they’re triggered.

Manual Badges

A badge can only be granted by an administrative user. See how to manually grant a badge.

Automatic Badges

Automatic badges are granted by special triggers. Discourse comes with a lot of default badges out of the box, but administrative users can also create custom ones. At their most basic, automatic badges are simple “kudos!” for users who are just starting out.

For example:

  • Added a link
  • Received a like.

Certain badges also coincide with new trust levels. When you’ve attained a new trust level, you’ll receive a corresponding badge to notify you of the bump-up.

  • Trust Level 1 --> Basic
  • Trust Level 2 --> Member
  • Trust Level 3 --> Regular
  • Trust Level 4 --> Leader

Want to create your own automatic badge? Go read how to trigger custom badge queries.

Badge Types - WIP

Bronze/Silver/Gold *What do they actually mean? Is it strictly a categorisation, or are there points attached to them?

Further Reading

How do I make my own badge query?
Best practice for Discourse badges
Plugin: Smart badge nominations based on Flags
How should Discourse System Market itself?
(Alex "Rota" Freeman) #2


After some googles and on-page-searches I was unable to find anything about custom badge series. What I mean by this is a series of two or more badges that contain SQL that removes the previous badge in the series and adds the current badge.

So for example I have unlocked “Custom Badge 1” by posting 100 posts, and on my 200th, I unlock “Custom Badge 2” which for business reasons should not share badge space with the previous badge, the “Custom Badge 1” would be programmatically removed from this user.

TL:DR; How to write a query that removes a badge in such a way to run concurrently with a badge awarding query?

(Mittineague) #3

I think it should be possible if the query uses the user_badges table likely using these fields in some manner.

badge_id    integer 
user_id    integer    fkey users 
granted_at    timestamp 

As long as “run revocation query daily” is enabled you could have the “first level” badge get revoked if the “next level” badge had been granted.

There may be a brief time between the grant and the revoke where a member might have both, but it would resolve itself within a day at most.

I recommend that you become more familiar with the Discourse database tables before you attempt crafting badge queries. They can be a “foot gun” and there is good reason it is slightly more work to get the interface functional.