# SQL Free Badge Editing

**URL:** https://meta.discourse.org/t/sql-free-badge-editing/60933
**Category:** Feature
**Created:** [April 13, 2017, 3:11pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933 "2017-04-13T15:11:41Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![nicatronTg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nicatrontg/32/103643_2.png) [@nicatronTg](https://meta.discourse.org/u/nicatronTg)
#### Post date: [April 13, 2017, 3:11pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/1 "2017-04-13T15:11:41Z")

</div>

Reading the [process for enabling custom badges](https://meta.discourse.org/t/badge-sql-can-no-longer-be-edited-by-default/47894), 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:

 ![](https://global.discourse-cdn.com/meta/original/3X/3/5/35088626bf2fd214b8b85d585b36f093a08663f3.png)

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).

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [April 13, 2017, 3:46pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/2 "2017-04-13T15:46:40Z")

</div>

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'
)

```

---

<div class="post-metadata">

### Author: ![nicatronTg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nicatrontg/32/103643_2.png) [@nicatronTg](https://meta.discourse.org/u/nicatronTg)
#### Post date: [April 13, 2017, 3:52pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/3 "2017-04-13T15:52:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [April 13, 2017, 4:06pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/4 "2017-04-13T16:06:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![nicatronTg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nicatrontg/32/103643_2.png) [@nicatronTg](https://meta.discourse.org/u/nicatronTg)
#### Post date: [April 13, 2017, 4:17pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/5 "2017-04-13T16:17:47Z")

</div>

> [@tobiaseigen](#):
>
> Actually I disagree with you - the system is plenty flexible, as long as you can turn on the custom sql queries.

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).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 13, 2017, 5:14pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/6 "2017-04-13T17:14:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [April 13, 2017, 5:44pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/7 "2017-04-13T17:44:46Z")

</div>

This is [something I’d love to have](https://meta.discourse.org/t/badge-sql-can-no-longer-be-edited-by-default/47894/5), 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.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [April 13, 2017, 6:02pm UTC](https://meta.discourse.org/t/sql-free-badge-editing/60933/8 "2017-04-13T18:02:20Z")

</div>

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