# 限制在“喜欢”一个主题前在某个分类中发帖

**URL:** https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191
**Category:** Support
**Tags:** automation
**Created:** [2026年二月26日 20:17 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191 "2026-02-26T20:17:03Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月26日 20:17 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/1 "2026-02-26T20:17:03Z")

</div>

下午好。我的网站上有一个“购买/出售/交易”类别，我想限制成员在该类别中发帖，直到他们“喜欢”规则主题。我问了 AI 机器人，它确实给我一些指示。然而，它似乎需要只有托管计划才可用的 Discourse 自动化。

我的自托管平台是否有办法做到这一点？

---

<div class="post-metadata">

### Author: ![darkpixlz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darkpixlz/32/549896_2.png) [@darkpixlz](https://meta.discourse.org/u/darkpixlz)
#### Post date: [2026年二月26日 20:22 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/2 "2026-02-26T20:22:08Z")

</div>

> [@R23D\_Printing](#):
>
> 我可以在我自托管的平台上做这个吗？

您好，它实际上是免费包含在社区版中的。您可以在“插件”选项卡中启用它。

---

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月26日 20:22 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/3 "2026-02-26T20:22:19Z")

</div>

没关系。我发现我可以手动添加 Discord 自动化插件……

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2026年二月27日 00:06 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/4 "2026-02-27T00:06:48Z")

</div>

嗯，也许可以通过 [Discourse Policy](https://meta.discourse.org/t/discourse-policy/88557) 和群组权限来实现？

> - **add-users-to-group** ：接受单个群组作为输入；接受该政策的用户将被自动添加到此群组中（当政策被手动撤销或政策版本更新时，用户将从群组中移除）

---

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月27日 00:15 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/5 "2026-02-27T00:15:59Z")

</div>

我弄明白了（在 [ask.discourse.org](http://ask.discourse.org) 的帮助下）。

我必须启用徽章 SQL，然后创建一个在有人喜欢特定帖子时分配的徽章。然后我创建了一个组，Discord 自动化会根据用户拥有该徽章自动分配。我让“everyone”组对该类别只有读取权限，这样他们只能进行反应。我给了自定义组完全的访问权限。

---

<div class="post-metadata">

### Author: ![ToddZ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toddz/32/328350_2.png) [@ToddZ](https://meta.discourse.org/u/ToddZ)
#### Post date: [2026年二月27日 01:15 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/6 "2026-02-27T01:15:32Z")

</div>

太棒了——感谢分享这些细节！  
现在你可以将你的帖子标记为你的解决方案了。😁

---

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月27日 01:16 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/7 "2026-02-27T01:16:41Z")

</div>

我回家后会写一篇关于我具体做了什么的简短记录，以防其他人想知道。然后我会将该记录标记为解决方案。

---

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月27日 16:58 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/8 "2026-02-27T16:58:34Z")

</div>

如果还有其他人有兴趣这样做，这是我所做事情的简短记录：

1. 首先，您需要通过 Discourse 服务器的 CLI 启用 Badge SQL：

```bash
./launcher enter app
rails c
SiteSetting.enable_badge_sql = true

```

1. 接下来，找到您希望成员互动的帖子 ID 才能获得徽章。在我的实例中，帖子 ID 是 117
2. 找到您希望成员互动的帖子 ID 才能获得徽章。在我的实例中，帖子 ID 是 117

![Screenshot 2026-02-27 113204](https://global.discourse-cdn.com/meta/original/4X/8/5/f/85f7bc087b5813f7ed8656d235c0554a84535f78.png)

1. 创建您的自定义徽章：
  1. 管理员 (Admin) \> 徽章 (Badges) \> 新建 (New)
  2. 将徽章命名为您想要的任何名称（例如 B/S/T 规则阅读者 (B/S/T Rule Reader)）
  3. 选择徽章类型、图标并为其提供描述
  4. 如果您遵循了第 1 步，您将看到一个可以输入 SQL 查询的查询框。粘贴此查询（将 `p.topic_id = 117` 更改为您自己的主题 ID）：
    1. 

```sql
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. 确保同时勾选 **每天运行撤销查询 (Run revocation query daily)** 和 **查询目标帖子 (Query targets posts)**。
  6. 触发器应设置为 **当用户对帖子执行操作时 (When a user acts on post)**

2. 现在我们创建自动化 (Automation)
  1. 首先创建一个新组，供成员添加。我的组仅命名为 `bst_rules_agreed`，并且设置为只有组所有者和版主可以看到成员身份。它不需要任何信任等级 (Trust Level) 影响。
  2. 接下来，转到插件 (Plugins) \> 自动化 (Automation)
    1. 添加一个新自动化
      1. 选择 **通过徽章进行用户组隶属关系 (User Group Membership Through Badge)**
      2. 触发器 (Trigger)：**定期 (Recurring)**
        1. 周期 (Recurrence)：我将其设置为每 1 小时一次。选择适合您的设置。
        2. 选择一个开始日期

      3. 脚本选项 (Script Options)：
        1. 徽章 (Badge)：选择您上面创建的徽章
        2. 组 (Group)：选择您上面创建的组

就这样。现在您应该有了一个系统，可以确保成员在能够在该类别中发帖之前已同意该类别的规则。

我接下来的探索是看看是否有办法向不属于该组的任何人隐藏除规则之外的所有主题。但是，这个基本系统目前已经足够好了。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2026年二月27日 17:01 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/9 "2026-02-27T17:01:47Z")

</div>

在关于私有话题插件的主题中提出了一个替代解决方案。我将其移至此处。

---

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月27日 12:02 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/10 "2026-02-27T12:02:40Z")

</div>

感谢您的这个插件！我一直在寻找一种方法在我们的社区中提供一个基本的工单系统。

我还在考虑将它用于我的“购买/出售/交易”分类。目前我设置的是每个人都可以阅读主题，但只有特定组中的人才可以回复和创建。目前的流程是：成员通过点赞帖子来确认他们已阅读规则。一旦他们点赞，就会获得一个自定义徽章。Discourse Automate 会根据徽章将他们添加到该组。

这可以阻止尚未接受规则的人在该分类中发帖。但是，他们仍然可以看到/阅读所有帖子。

那么，如果我将所有人从该分类中移除，只在安全选项卡中保留该自定义组，它会起作用吗？只要我让管理员组的帖子始终可见，不在自定义组中的人仍然可以看到并点赞规则吗？然后，一旦他们点赞并被添加到该组，所有内容对他们开放了吗？

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2026年二月27日 12:06 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/11 "2026-02-27T12:06:40Z")

</div>

> [@R23D\_Printing](#):
>
> 然后，一旦他们点赞并被添加到群组，对他们来说一切都开放了？

这个插件的目的不是这样的。

您的情况可以不使用此插件来实现，而是使用 [Discourse Policy 插件](https://meta.discourse.org/t/discourse-policy/88557)，该插件有能力将接受政策的用户添加到群组中。

> [@Discourse](#):
>
> **add-users-to-group** ：接受单个群组作为输入；接受政策的用户将被自动添加到此群组中（当政策被手动撤销或政策版本更新时，用户将从群组中移除）

---

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月27日 12:38 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/12 "2026-02-27T12:38:09Z")

</div>

在我深入研究我最终分配组成员身份的方式之前，我查看了策略（Policy）插件。我不喜欢使用策略来处理此问题的原因是它必须应用于一个组。我需要将其应用于类似 `trust_level_1` 的内容，以确保所有想要成为 B/S/T 一部分的人都能看到它。但是，并非所有人都想参与 B/S/T。我不想因为他们不感兴趣而用另一个需要点击的东西（即使很快）去烦扰他们。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2026年二月27日 15:54 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/13 "2026-02-27T15:54:01Z")

</div>

> [@R23D\_Printing](#):
>
> . 我不喜欢该策略的原因是它必须应用于一个组。我需要将其应用于像 trust\_level\_1 这样的组，以确保所有想参与 B/S/T 的人都看到它。但是，并非所有人都想参与 B/S/T。

- 创建一个名为“BST 申请人”的组和一个名为“BST 成员”的组
- 让“BST 申请人”成为一个可以自由加入的组
- 制定一个适用于“BST 申请人”并将其添加到“BST 成员”的策略
- 授予“BST 成员”访问该类别的权限

人们将加入“BST 申请人”，接受策略并成为“BST 成员”的一员。这很麻烦，但比通过点赞帖子来触发一个完整的鲁布·戈德堡机械要麻烦得少。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2026年二月27日 18:48 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/14 "2026-02-27T18:48:21Z")

</div>

2 个帖子已合并到现有主题：[Private Topics Plugin](https://meta.discourse.org/t/private-topics-plugin/268646/99)

---

<div class="post-metadata">

### Author: ![R23D\_Printing](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/r23d_printing/32/544902_2.png) [@R23D\_Printing](https://meta.discourse.org/u/R23D_Printing)
#### Post date: [2026年二月27日 17:09 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/15 "2026-02-27T17:09:17Z")

</div>

这也可以奏效。我会研究一下。谢谢！！我真的是 Discourse 的新手，所以正在学习它的用法。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2026年三月29日 18:49 UTC](https://meta.discourse.org/t/restrict-posting-in-a-category-until-they-like-a-topic/397191/16 "2026-03-29T18:49:06Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
