Discourse 政策

:discourse2: Summary Discourse Policy gives the ability to confirm your users have seen or done something, with optional reminders.
:open_book: Install Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.

Features

Discourse policy shares much of its DNA with polls, it has the goal of ensuring members of a group accept certain policies by clicking a button.

It has some specific features that set it apart from polls:

  1. It must apply to a group.

  2. It can optionally nag members of a group either weekly or daily to click accept on a policy.

  3. The UX makes it very easy to see who accepted and who did not accept a policy.

Configuration

Screenshots

Before clicking accept

After clicking “grey” person on top right

After clicking accept

Creating a policy

Discourse policy registers a custom [policy] BBCode element. Which means you need to write this block of code in your post where you want to show this policy.

[policy group=founders reminder=daily]
I accept this policy will annoy me daily until I click accept
[/policy]

In this case the policy applies to the founders group and a reminder is sent daily to all users that did not accept the policy.

Site settings

policy_enabled : Enable the discourse policy plugin on the site.

policy_restrict_to_staff_posts: Policies may only appear on staff posts.

policy easy revoke: Show the accept and revoke buttons at the same time.

BBCode attributes

The [policy] element can accept the following attributes.

  • group: the group name that policy will apply to required
  • version: the version number of the policy, bump number up to require all users re-accept the policy
  • reminder: remind users of the group to accept policy (weekly or daily), optional, default off
  • accept: text used for accept button, default is “Accept Policy”
  • revoke: text used for revoke button, default is “Revoke Policy”
  • renew: number of days or text describing period (monthly, quarterly or yearly) after which a user needs to re-accept policy
  • renew-start: the first date renewals will start at Eg: 17-10-2017, useful if you want to set the renewal cadence so it happens every half-year (Jan,June)
  • 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)
  • private: hide users who accepted/did not accept the policy

:information_source: The backend job to check for policy reminders runs every 6 hours. If the reminder element is set to weekly or daily, users who have not accepted a policy will be sent notification reminders to accept the policy only if they have not already received a reminder notification for the policy within the past week or day.

Usage examples

Basic policy:

[policy group="team" reminder="daily" accept="Accept" revoke="Ignore" version="1"]
I have read, understand and acknowledge this policy.
[/policy]

Bumping the revision number, to require that everyone reads the update:

[policy group="team" reminder="daily" accept="Accept" revoke="Ignore" version="2"]
I have read, understand and acknowledge this policy. (Last updated [date=2020-04-23 timezone="America/Los_Angeles"])
[/policy]

Periodic auditing task:

[policy group="audit_committee" reminder="weekly" renew="90" renew-start="01-07-2019" version="1" accept="Assignment Complete"] 
I have ensured that someone is assigned to this quarterly audit task.
[/policy]

CHANGELOG

TODO

  • Optional immediate reminder for new policies
  • Possibly allow certain groups to apply policies (expanding on staff)

Last edited by @david 2025-07-22T13:14:42Z

Check documentPerform check on document:
65 个赞

2 篇帖子已拆分到新主题:将策略创建限制为仅限员工?

4 个帖子已拆分为新主题:是否可以禁止撤销对某些策略的同意?

看起来此提交删除了 200 的限制和 policy_max_group_size。我是否遗漏了什么?

3 个赞

6 个帖子被拆分到一个新主题:即使接受了政策,人们仍收到提醒

当应用于大型群组的长按钮文本策略时,UI 会被破坏:在下面的屏幕截图中,我们可以看到头像形成了一个近乎无限的列,这有点尴尬。我将查看 CSS,看看是否可以轻松修复,但可能需要进行某种重新设计:

删除 .cooked .policy .user-lists 上的 display: flex 会使其在桌面上的显示效果正常:

我最终使用了以下 CSS:

/* 使策略用户列表不溢出 */
.cooked .policy .user-lists {
    display: block;
}
3 个赞

安装插件后出现错误。不知道为什么。似乎与“尝试加载 /admin/dashboard/general.json”有关。

服务器错误

尝试加载 [/admin/plugins] 时

错误代码:500 错误

糟糕

此论坛软件遇到了意外问题。我们对造成的不便深表歉意。

错误详情已记录,并已生成自动通知。我们将进行查看。

无需进一步操作。但是,如果错误状况持续存在,您可以通过在该网站的反馈类别中发布讨论主题来提供更多详细信息,包括重现错误的步骤。

您好,

如果策略位于不允许回复的“分类主题”中,是否还会显示“接受/撤销”按钮?

谢谢

我有一段时间没用过这个插件了,但我认为它将允许用户在主题关闭时接受/撤销,因为按按钮不算回复,而这正是关闭所阻止的。

1 个赞

嗨,我有一个问题:
我们想使用 Discourse Policy 插件来:强制首次用户接受服务条款 (ToS)。要求:

  • 如果他们不接受 → 他们不能使用论坛(只能看到 ToS 页面)
  • 当他们接受 → 他们可以使用论坛 + 获得一个 “ToS” 徽章

我的解决方案是创建一个新主题,并在其中添加了以下内容:
[policy group=trust_level_0 reminder=daily add-users-to-group=tos_accepted accept=“我接受条款” version=“1”]
点击“我接受条款”,我确认我已阅读并同意服务条款。
[/policy]

但是如果一个新用户登录,策略根本不显示,他可以做任何他想做的事情,我们希望只有在他点击“接受”后才能访问我们的页面。 如何做到这一点,谢谢

您可以使用自定义字段并链接服务条款和常见问题解答页面。用户阅读后将收到“已读指南”徽章。

2 个赞

感谢您的回复——它正如您所说的那样奏效了。但是,我真正想要的是在用户登录后显示此横幅,并且只有在用户单击“接受”后才允许访问该页面。如果用户不单击“接受”,横幅应保持可见,并且用户将无法与页面进行交互。

我现在拥有的是:


在此之后,用户可以正常访问我们的页面。

有什么方法可以做到这一点吗?谢谢。

:partying_face: 此插件现已作为 Bundling more popular plugins with Discourse core 的一部分,随 Discourse 核心一起提供。如果您是自托管用户并使用了此插件,则需要在下次升级前将其从 app.yml 中移除。

3 个赞

如果能添加在接受或拒绝移除用户组的功能就太好了。

目前此功能仅会(可选地)提醒用户,并且添加用户——除非我遗漏了什么。

谢谢!

1 个赞