Restrict posting in a category until they "like" a topic

Good afternoon. I have a Buy/Sell/Trade category on my site that I’d like to restrict posting in until a member “likes” the rules topic. I asked the AI Bot, and it did give me some instructions. However, it seems that it requires Discourse Automation that is only available on hosted plans.

Is there a way that I can do this on my self-hosted platform?

Hi, it is actually bundled with the community edition for free. You can enable it in the Plugins tab.

2 Likes

Nevermind. I figured out that I can add the Discord Automation plugin manually…

1 Like

Hmm, perhaps with Discourse Policy and group permissions?

  • add-users-to-group: accepts a single group as input; users who accept the policy will be automatically added into this group (when policy is manually revoked or if the policy version is updated, user(s) gets removed from group)
2 Likes

I figured it out (with the help of ask.discourse.org).

I had to enable badge sql and then create a badge that is assigned when someone likes the specific post. I then created a group that Discord Automation auto assigns based on a user having the badge. I have the “everyone” group only read access to category so they can only react. I gave the custom group full access.

2 Likes

Nice – thanks for sharing the details!
Now you get to mark your post as your solution. :grin:

1 Like

I’m going to do a little write up on exactly what I did when I get home, just in case someone else wants to know. Then I’ll mark that as the solution.

3 Likes

Just in case anyone else is interested in doing this, here is a short writeup of what I did:

  1. First, you need to enable Badge SQL through your Discourse server’s CLI:
./launcher enter app
rails c
SiteSetting.enable_badge_sql = true
  1. Next, find the ID of the topic that you want the members to interact with in order to get the badge. In my instance, the topic ID is 117

Screenshot 2026-02-27 113204

  1. Create your Custom Badge:
    1. Admin>Badges>New
    2. Name the badge whatever you want (ex. B/S/T Rule Reader)
    3. Choose a badge type, icon, and give it a description
    4. If you followed Step 1, you will see a query box where you can type in a SQL query. Paste this query (change p.topic_id = 117 to whatever your topic ID is):
      1. SELECT DISTINCT ON (pa.user_id)
          pa.user_id,
          pa.post_id,
          pa.created_at granted_at
        FROM post_actions pa
        JOIN posts p ON pa.post_id = p.id AND p.post_number = 1
        WHERE pa.post_action_type_id = 2
          AND p.topic_id = 117
          AND (:backfill OR pa.post_id IN (:post_ids))
        
    5. Make sure Run revocation query daily and Query targets posts are both checked.
    6. The trigger should be set to When a user acts on post
  2. Now we create the Automation
    1. First create a new group for the members to be added to. Mine is just named bst_rules_agreed, and it is set so only group owners and mods can see the membership. It does not need any kind of Trust Level effects.
    2. Next, go to Plugins>Automation
      1. Add a new automation
        1. Choose User Group Membership Through Badge
        2. Trigger: Recurring
          1. Recurrence: I have mine set to every 1 hour. Choose what makes sense to you.
          2. Choose a start date
        3. Script Options:
          1. Badge: Choose the badge you created above
          2. Group: Choose the group you created above

That’s it. You should now have a system that makes sure members have agreed to the rules of the category before they are able to post in the category.

My next exploration is to see if there is a way to hide all topics except the rules to everyone that isn’t in that group. But, this basic system is good enough for now.

1 Like

An alternative solution was suggested in the topic for the private topics plugin. I am moving that here.

1 Like

Thanks for this plugin! I was looking for a way to provide a basic ticketing system in our community.

I’m also thinking of using this in my Buy/Sell/Trade category. Right now I have it set where everyone can read topics, but only people in a specific group can reply and create. The current workflow is: Member acknowledges that they read the rules by liking the post. Once they like the post, they are granted a custom badge. Discourse Automate adds them to the group based on the badge.

This stops people that haven’t accepted the rules from posting in the category. However, they can still see/read all of the postings.

So, would it work if I remove everyone from the category and only have that custom group in the security tab? As long as I have posts from the Admin group always visible, would people not in the custom group still be able to see and like the rules? Then, once they like and are added to the group, everything opens for them?

That is not what this plugin was meant to do.

Your use case can be implemented without this plugin, using the Discourse Policy plugin instead, which has the ability to add users who accepted the policy to a group.

I looked at the Policy plugin before I started down the rabbit hole of the way I ended up assigning the group membership. The reason I don’t like the Policy for this is because it has to be applied to a group. I would have to apply it to something like trust_level_1 to make sure everyone that wants to be a part of B/S/T sees it. But, not everyone wants to participate in B/S/T. I don’t want to hound them with another thing to click (even though it is quick) if they aren’t interested in it.

  • make a group “BST applicants” and a group “BST members”
  • have “BST applicants” be a group that can be freely joined
  • have a policy which applies to “BST applicants” and adds to “BST members”
  • grant “BST members” access to the category

People will join “BST applicants”, accept the policy and become member of “BST members”. Hairy but less hairy than triggering a complete Rube Goldberg machine by liking a post.

1 Like

2 posts were merged into an existing topic: Private Topics Plugin

This could work as well. I’ll investigate it. Thank you!! I am really new to Discourse, so I’m learning the ways.