Im assuming this needs to be replaced with the post URL including the ‘/1’?
That bit needs to be replaced with the link they’re clicking on within the post.
And the post_id is the post in which the link is pasted/shared.
Oh I see, so there is no way to just grant the badge just by them visiting the post link?
I think there should be, but that would be a different query. This one awards a badge for clicking on a specific link in a specific forum post.
If you want to award a badge for a user visiting a particular topic I think it would be:
SELECT DISTINCT tv.user_id, MIN(tv.viewed_at) granted_at FROM topic_views tv WHERE tv.topic_id = 728 GROUP BY tv.user_id
(Replacing ‘728’ with the relevant topic_id)
Okk so I have it setup like so:
But when I visit the post in question (as an Admin), I do not get the badge. Am i don’t something wrong here?
As it needs the Update Daily trigger, it will be granted the next time the daily badge grant job runs. You can manually trigger
Jobs::BadgeGrant from your
/sidekiq/scheduler page if you want to speed it up to check.
How can I make it update instantly?
The only available triggers are:
- Update daily
- When a user edits or creates a post
- When a user is edited or created
- When a user acts on a post
- When a user is edited or created
- When a user changes trust level
To have a more instant badge granted, you would need to work within the confines of those actions. You can read more in this topic - Create Triggered Custom Badge Queries
I did this but still not been granted yet.
FWIW, it works for me.
Have you enabled it? And have you made sure you have the correct topic number set?
Yes it’s enabled. Let me try on another profile. Maybe its because I am the admin.
Secondly, are you just pasting the topic link into your browser?
Being admin doesn’t make a difference for this one.
You would need to visit the topic for it to register in the
topic_views table this badge is based on.
Still nothing, I tried visiting based on the URL directly, clicking on it from search, and clicking from the ‘Latest’ topics page.
Triggered this, and still nothing.
And you’re using the topic_id and not the post_id for this one?
There you go, this was the problem lol. Sorry about that. It’s working now.
Next question, can we upgrade a users trust level based on them being granted a badge?
And can we hide a topic entirely from public view and only make it visible via direct link?
There is a brand new ‘User Group Membership through Badge’ script for the automation plugin that may be suitable - though rather than adding them to a Trust Level group directly I think I would consider adding them to a custom group which granted a particular trust level (that way they shouldn’t be downgraded when the trust levels are periodically recalculated).
For this, I’m thinking Unlisting the topic is likely the best route. Unlisting does still send out notifications though for anyone Watching/Watching First Post a category, so you may also want to consider creating a brand new subcategory to put it in which nobody will have had a chance to start Watching yet.
how do I add them to a custom group based on them being granted a badge, and then how do I grant them the trust level based on being in the group ?
where can I find this script
You would use the Automation script (see below). As part of creating a group, you can assign a trust level to be automatically granted with it:
It’s part of the Automation plugin:
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.