SQL Free Badge Editing

Reading the process for enabling custom badges, I think that it’s worth discussing the idea of having a badge editor that doesn’t require SQL to manage in the first place. Since disabling SQL editing, badges are very decorative in the admin panel with no obvious note that editing them is possible in the first place.

In XenForo, you can create custom trophies and setup triggers like this:

I think it should be apparent and obvious that this isn’t the most flexible system in the world, but it does provide a level of individuality right out of the box for a forum, without exposing SQL to administrators.

I don’t know how this data is modeled internally, and I don’t think it’s the easiest to implement, but it would at least provide some replacement functionality for the SQL trigger section that badges currently have (albeit, hidden).


I like all this and would like to see it implemented, though most of the options available in your screenshot are not really relevant to my community.

User groups is important though - I think if the query below were hard coded to a badge option alot of sites would not need to turn on the SQL queries options. I know that the vast majority of badges on my site that I needed to custom create are based on this query. GROUPNAME would be the name of a discourse group that could be specified on the badge settings page, e.g. “Assign this badge to users in this group”.

select user_id, created_at granted_at, NULL post_id
from group_users
where group_id = (
  select g.id from groups g where g.name = 'GROUPNAME'

Yeah – I agree that it’s not nearly the most flexible system that it could be. I could see it being dramatically useful to have at least a set of operators on the basic statistics – but it’s kinda difficult to design storage and computation wise.

I’d be willing to see this is as a plugin, though I think that since badges are a very core feature, editing should be a first class citizen too. Maybe this isn’t the right fit for a core developer to work on (GSoC idea?) – but with a crystalized design it could be something worthy of a large scale development effort and associated pull request.

Actually I disagree with you - the system is plenty flexible, as long as you can turn on the custom sql queries. But for those who aren’t able to, adding the ability to assign badges automatically based on groups would be a valuable addition to the existing badges.

It’s a fair point, but I didn’t even know that turning on custom SQL was an option or that the feature existed. Like I said, the point of this feature request is to remove the need to enable custom SQL in the first place (which is a security concern, and why it was disabled by default in the first place).

I would rather add more useful badges in each release, for example in 1.8 we added the new user of the month badge.

1 Like

This is something I’d love to have, but it’d require quite a lot of work. The super tricky part is making it flexible enough that any admin user could create almost any type of query that requires handwritten SQL today, without being able to bring the whole forum down with a bad query.

It’s unlikely that we’ll add anything like this to core in the near term. I’m sure a lot of people would be interested in this as a plugin though. IMO this is so advanced that it should be a premium plugin.

1 Like

Agreed about the complexity. IMHO it would be better to have “badge wanted” ideas floated.