# Grant Custom Badge Upon Reading ToS

**URL:** https://meta.discourse.org/t/grant-custom-badge-upon-reading-tos/368259
**Category:** Data & reporting
**Tags:** sql-triggered-badge
**Created:** [May 30, 2025, 3:10pm UTC](https://meta.discourse.org/t/grant-custom-badge-upon-reading-tos/368259 "2025-05-30T15:10:18Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![TempAccount](https://avatars.discourse-cdn.com/v4/letter/t/a9a28c/32.png) [@TempAccount](https://meta.discourse.org/u/TempAccount)
#### Post date: [May 30, 2025, 3:10pm UTC](https://meta.discourse.org/t/grant-custom-badge-upon-reading-tos/368259/1 "2025-05-30T15:10:18Z")

</div>

Continuing the discussion from [How does the reader / read guideline badges work?](https://meta.discourse.org/t/how-does-the-reader-read-guideline-badges-work/26264):

How would someone repurpose this for a custom badge, where the user will be automatically awarded upon reading the terms?

* * *

### Resource found:

This for the “read guidelines” badge:

> [@The default badge queries](https://meta.discourse.org/t/the-default-badge-queries/276812#p-1354278-h-3rd_place_medal-read-guidelines-25):
>
> This is a reference guide for the SQL queries of the default badges, and their trigger information (where available). Core Badges 2nd_place_medal Anniversary (This one has some extra backend magic in to choose the dates, but I’ll include it anyway) start\_date = start\_date.iso8601(6) end\_date = end\_date.iso8601(6) SELECT u.id FROM users AS u JOIN posts AS p ON p.user\_id = u.id JOIN topics AS t ON p.topic\_id = t.id WHERE u.id \> 0 AND u.acti…

and also this… although I don’t know where to insert the SQL for the badge:

> [@Badge for reading a topic?](https://meta.discourse.org/t/badge-for-reading-a-topic/281534/2):
>
> I think this should be possible with something like: SELECT user\_id, CURRENT\_TIMESTAMP AS granted\_at FROM topic\_users WHERE topic\_id = 281534 AND total\_msecs\_viewed/60000 \>= 5 -- min number of minutes viewed

…as well as the underlying question if `/tos` is considered a topic if users can only see it from the view of the tabs:

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/4/7/547c2e6c492dfc6f8325a876d41b0add095a18b7.png)

---

_[View the full topic](https://meta.discourse.org/t/grant-custom-badge-upon-reading-tos/368259)._
