How can I apply a badge to group of users?

(John Mardlin) #1

I’m trying to incentivize the engagement of some of our most valuable community members, who are beta testers for our product.

To do so, I’ve created a Beta group, and created a hidden topic for to discuss the beta product.

I would also like to grant all of these users a publicly visible Beta badge, so that they can have some credibility, feel appreciated, etc.

  1. Is it possible to apply a badge to an entire group?

  2. At the moment, I’m actually not sure the best way to add a badge to a user, aside from going right into …/admin/users/user_name/badges, is there a better way?

2 Likes

Configuring Patreon integration with Discourse
(Jens Maier) #2

Sam posted this earlier today:

It should be possible to adapt this to assign a badge to all members in a group by group name:

SELECT gu.user_id, gu.created_at AS granted_at, null AS post_id
FROM group_users AS gu
WHERE gu.group_id = ( SELECT id FROM groups WHERE name ilike 'beta' );
8 Likes

Assign specified badge a single user
How are user titles generated?
(Kane York) #3

I would recommend either finding the precise group ID and just pasting that in, or having an exact equality on the group name.

1 Like

(Passante) #4

After one year, a lot as been done on the badge side. Greate work!
Now I want to ask the same question of the OP.
Is it possible to assign and show an image like this for a user or a group?
My team is pressing me since the beginning :sweat_smile:

0 Likes

(cpradio) #5

So it where? Badges can receive an image URL when you set them up. So just upload the image to your assets page, then grab the link and associate it to the badge.

0 Likes

(Jens Maier) #6

Badges, stars or other eyecandy that appears near the user’s avatar or name on each and every post isn’t supported in Discourse by default. This would be plugin territory… :slight_smile:

1 Like

#7

Hey guys, is it ok to use the above SQL statement to assign badges to group members?

If I add the query to the badge query section, when will it run and issue badges? Is it daily?

Many thanks

Edit: It appears to work when I preview granted badges - can anybody shed some light on when the query is run?

0 Likes

(Sam Saffron) #8

Badges like this usually run daily

3 Likes

#9

Works great thank you - and as you say, daily.

1 Like

(Sebastian) #10

Just trying this out and when previewing I get an error saying

Contract violation:
Query triggers on users, but does not reference the ':user_ids' array
0 Likes

(Daniela) #11

Change the trigger of the badge in daily

1 Like

(Christoph) #12

Good point. Where do I find the precise group ID of a given group?

0 Likes

(cpradio) #14

You can visit https://www.example.com/groups.json

That will give you an JSON output that has the ID and names of each group

2 Likes