Add Badge to Solve answer


Based on this post and screenshot, there is a way to add a badge to solve answers. - Discourse Solved (Accepted answer plugin)

But on the latest plugin, no option is available. How do I add or associate a badge to solve answers now?


(Daniela) #2

Are you talking of this query?

SELECT p.user_id, post_id, p.updated_at granted_at
FROM badge_posts p
WHERE p.post_number > 1 AND IN (
      SELECT post_id FROM (
       SELECT pc.post_id, row_number() 
       OVER (PARTITION BY p1.user_id ORDER BY pc.created_at) as rnum
       FROM post_custom_fields pc
       JOIN badge_posts p1 ON = pc.post_id
       JOIN topics t1 ON p1.topic_id =
       WHERE name = 'is_accepted_answer' AND
                     value IS NOT NULL AND
                    p1.user_id <> t1.user_id AND 
          :backfill OR 
           p1.user_id IN (
                   select user_id from posts where IN (:post_ids)
) X  WHERE rnum = 1)

You need to follow this topic: Badge SQL can no longer be edited by default
Then create a new badge in

Badge SQL Error: q.user_id
Badge SQL Error: q.user_id

Thanks @Dax.

If I’m correct, once I enabled the creation a new bad, I can just add this code and no need to check something on the plugin to enable it?

OLD example of the plugin-solved:

(Daniela) #4

Allow badges to be awarded in this category does not refer to the solved plugin in particular, but to all the Discourse badges in general. You do not have to check anything, just that the plugin is enabled globally or on the individual categories as @awesomerobot explained to you here Added latest version of plugin-solved - Checkbox for OP is not showing