Grant Badge when user visits link

I’m not 100% sure I’m following the method you’re using for this? You may want to have a check that you’re not overcomplicating the setup.

If checking the json isn’t your cup of tea, then a post_id lookup query would be something like this:

-- [params]
-- topic_id :topic_id
-- int :post_number

SELECT id
FROM posts 
WHERE topic_id = :topic_id
  AND post_number = :post_number

Then you can use the URL of the post to pull out the topic id and post number to enter into the parameter boxes. eg: https://meta.discourse.org/t/grant-badge-when-user-visits-link/276700/4 (worth noting that the OP is always post_number 1, even if it’s not in the topic link)


Actually, there’s a magic parameter that might make looking up a post_id using the data explorer even easier…

-- [params]
-- post_id :url

SELECT id 
FROM posts
WHERE id = :url

Paste the relevant URL for the post into the parameter box, et voila - it pops out the post_id :slight_smile:

post_id

1 Like