# 创建组件以限制用户状态的人员数量

**URL:** https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214
**Category:** Development
**Tags:** user-status
**Created:** [2023年三月29日 20:41 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214 "2023-03-29T20:41:26Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年三月29日 20:41 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/1 "2023-03-29T20:41:26Z")

</div>

> [@Lilly](#):
>
> 我喜欢这个功能，但只想对我们员工启用——能否将其限制在特定用户组内？我知道我们的大多数用户可能会滥用这个功能，或者至少以非预期的方式使用它。

@Lilly 如果你感兴趣，可以试试这个组件 [GitHub - Arkshine/discourse-restrict-user-status: A theme component to restrict user status access to groups. · GitHub](https://github.com/Arkshine/discourse-restrict-user-status)

编辑：一旦它完全可用，我会在 #Customization > Theme component 板块创建一个主题。

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [2023年三月29日 20:54 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/2 "2023-03-29T20:54:06Z")

</div>

干得好 @Arkshine 😃

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年三月31日 21:14 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/4 "2023-03-31T21:14:35Z")

</div>

谢谢。我试了几次，该组件仍然无法限制访问。例如，我将其限制为管理员（我）和我的测试用户帐户可以访问用户状态功能。

更新：此后，我也尝试了员工和版主组，但均未成功。就好像该组件未启用一样，但它确实已启用。🤔

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年三月31日 21:26 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/5 "2023-03-31T21:26:03Z")

</div>

请确保您拥有最新版本（如果还没有的话）。

另外，从我在您的论坛上看到的情况来看，`enable_user_status` 被禁用了。🤔

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年三月31日 21:27 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/6 "2023-03-31T21:27:01Z")

</div>

是的，在我无法使其正常工作后，我将其禁用了。等我回到办公桌后，我会再处理它。我真的不希望我的用户拿到它，哈哈。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年三月31日 21:38 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/7 "2023-03-31T21:38:28Z")

</div>

好的 😄。

它对我来说绝对有效。我唯一能想到的问题是，您可能在设置中保留了“everyone”组（因为它是默认值，我可能应该删除它 🤔）。

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年三月31日 22:28 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/8 "2023-03-31T22:28:51Z")

</div>

我试了几次，但都没有成功。管理员是唯一在允许组设置中的组。我必须不断地打开和关闭用户状态设置来测试它，所以也许这就是原因。我现在把它关掉了。

换句话说，我可以在管理员设置中全局关闭用户状态，但无论我在允许区域使用什么组，该组件似乎都没有任何效果。我在适用的主题上启用了该组件。

更新。好的，它允许每个人从用户菜单访问该设置，并允许您填写时间等，但它没有显示在头像或用户卡中。仍然可以在个人资料中显示。

不管怎样，这没什么大不了的。我喜欢这个功能，适合员工使用，但等我有更多时间的时候再研究。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年三月31日 23:02 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/9 "2023-03-31T23:02:33Z")

</div>

我在你们的论坛上（不太确定）认为它对我来说是有效的。  
我可以看到组件已加载（我也看到了一个警告，它已经修复了），并在查看个人资料之前检查了站点设置（使用浏览器控制台）是否已启用 🤔

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/8/2/88295fd512351b066c77efda39310e30103a96b8.png)

另外，只是为了让你看到，它在我这边是有效的：

> **演示**
>

让我看看我是否能弄清楚发生了什么。  
感谢测试。 😄

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年四月1日 12:49 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/10 "2023-04-01T12:49:14Z")

</div>

经过今天早上几次尝试，我仍然无法让它正常工作。它允许我的测试帐户看到“设置用户访问”选项并访问“设置用户状态”对话框，并从用户菜单输入详细信息，但无法访问首选项页面。即使从用户菜单设置，状态似乎也不会显示在头像或个人资料中。因此，基本上它似乎部分有效，但并未阻止最初访问设置。我还使用了两个设备，一个以管理员身份登录，另一个以测试用户身份登录。但是，当我更改设置时，我会注销并刷新测试帐户。

管理员设置：

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/9/9/399a0aa0aac208cd61b7e3f307c768ec26d4fe3d.jpeg)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/0/0/c/00c930a30144b3dd92748fe5887e03b4ed0ae521.jpeg)

测试用户：

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/7/0/270b7e5ca64982f2d6c5bd07b2e129478d0db14b.jpeg)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/2/a/8/2a88249eea959570ed96c34fa2436d0fe219514c.jpeg)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/7/7/0/770f3df7c5593dd59675a84e02f755bbc14c20f1.jpeg)

我现在将再次关闭用户状态设置。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年四月1日 13:26 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/11 "2023-04-01T13:26:44Z")

</div>

这是个好消息。如果部分可用，我可以修复它。😄  
我刚看到您正在使用旧菜单，我可以确认它没有被处理。  
让我看看我是否能匹配您所有的设置，以及我是否遗漏了某些区域！  
感谢您的测试和耐心。

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年四月1日 14:17 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/12 "2023-04-01T14:17:05Z")

</div>

哈哈。我忘了那个了。我想我会启用新的。它差别不大。我更关心侧边栏汉堡菜单，因为我知道我的用户群会对这个改变提出更多抗议，尽管我喜欢侧边栏，它好多了，并且也能解决他们的一些导航问题。我将在某个时候启用侧边栏。

如果我能让这个组件与更新的用户菜单一起工作，我就满意了。

编辑：不行

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/5/2/152ef94a6fdd51da7e51f057b6698115ffe8c479.jpeg)

但感谢你提醒我旧菜单，我本来打算启用它的。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年四月1日 14:22 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/13 "2023-04-01T14:22:12Z")

</div>

抱歉在错误的版块发送了垃圾信息。@JammyDodger 🫠

@Lilly 不，别担心，我会处理好一切。我已经将修复程序推送到旧菜单了，但目前正在测试边缘情况；给我一些时间，我会尽快回复你！

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年四月1日 14:23 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/14 "2023-04-01T14:23:40Z")

</div>

不着急！谢谢。是的，抱歉我到处乱发帖。🤦‍♀️

仅供参考，我已更新组件以获取您的最新版本，但仍存在同样的问题。

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2023年四月1日 16:25 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/15 "2023-04-01T16:25:08Z")

</div>

> [@Arkshine](#):
>
> 抱歉在错误的部分发送了垃圾信息。@JammyDodger 🫠

没关系，我的魔法按钮就是为此而生的。🙂 我把它从主帖中分离出来，给你更多空间来探索这个想法并弄清楚一切。🤞

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年四月1日 19:33 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/17 "2023-04-01T19:33:55Z")

</div>

您打算仅将其用于管理员/版主（而不是特定的自定义组）吗？如果是这样，我认为我会为您创建一个特定版本。

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年四月1日 19:41 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/18 "2023-04-01T19:41:53Z")

</div>

是的，正是如此。我希望用户状态功能仅供工作人员（管理员和版主）使用，如果他们想使用的话。我们的版主时而在，时而不在线，有时会不规律地不在线，尤其是在即将到来的旺季，届时我们会收到更多标记，他们需要互相照顾。由于我只有管理员权限，我希望我的工作人员和用户知道我何时在线或将长时间不在线。但是，我不想为我的特殊情况启动一个大项目。当实际的用户状态功能不再是实验性的时，有一个群组功能或至少是仅限工作人员的功能会很好。

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [2023年四月1日 20:04 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/19 "2023-04-01T20:04:25Z")

</div>

我喜欢这个！但这是否只会让事情变得更难，因为如果用户真的想这样做，他们仍然可以使用检查元素来做到这一点？

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2023年四月3日 08:32 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/20 "2023-04-03T08:32:18Z")

</div>

只是提前通知你一下 @Arkshine，我们可能正在考虑为核心功能添加一个“启用分组”的设置。 👍

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [2023年四月3日 11:22 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/21 "2023-04-03T11:22:51Z")

</div>

这是个好消息。谢谢你的更新。

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2026年一月18日 18:42 UTC](https://meta.discourse.org/t/creating-a-component-to-staff-limit-user-status/260214/23 "2026-01-18T18:42:52Z")

</div>

现在她做了一个插件 🎊 [Discourse Group User Status](https://meta.discourse.org/t/discourse-group-user-status/393748/1)
