# 能够创建一个用户组，其中包含与具有特定电子邮件域的用户“相反”的用户

**URL:** <https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336>\
**Category:** Feature\
**Created:** [2023年七月21日 00:07 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336 "2023-07-21T00:07:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)\
**Post date:** [2023年七月21日 00:07 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/1 "2023-07-21T00:07:52Z")

</div>

我想创建一个用户组，包含所有人，_除了_那些拥有例如 `@domain.com` 的人。这在 Discourse 中是否可行？

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2023年七月21日 00:39 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/2 "2023-07-21T00:39:00Z")

</div>

我相当确定您需要一个自定义插件。

我认为这会很简单，一两个小时，具体取决于细节，例如配置的难易程度以及是否有规格。

---

<div class="post-metadata">

**Author:** ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)\
**Post date:** [2023年七月21日 00:42 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/3 "2023-07-21T00:42:56Z")

</div>

再想想……这不仅会是一个很棒的功能，而且还能够根据数据浏览器查询创建动态用户组。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2023年七月21日 00:56 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/4 "2023-07-21T00:56:24Z")

</div>

或者能够使用徽章 SQL 来授予一个徽章，该徽章可以将某人添加到组中。那也会很容易。

---

<div class="post-metadata">

**Author:** ![hello-smile6](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hello-smile6/32/304628_2.png) [@hello-smile6](https://meta.discourse.org/u/hello-smile6)\
**Post date:** [2023年七月21日 02:47 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/5 "2023-07-21T02:47:23Z")

</div>

[quote=“Jay Pfaffman, post:4, topic:272336, username:pfaffman”]授予一个徽章，将某人添加到某个组  
[/quote]

我相信电子邮件地址会在用户帐户创建时通过 webhook 有效负载发送，那么这是否也可以使用 webhook 和 API 来实现（例如，对于无法使用徽章 SQL 的 CDCK 托管站点）？

---

<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:** [2023年七月21日 09:09 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/6 "2023-07-21T09:09:30Z")

</div>

> [@hello-smile6](#):
>
> 我相信电子邮件地址会在用户帐户创建时发送到 webhook 负载中

是的，我确认它们是。🙂

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2023年七月21日 19:04 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/7 "2023-07-21T19:04:43Z")

</div>

因此，您可以使用自动化工具来更新群组，例如 [使用 Discourse Webhook 触发 Zapier 任务](https://meta.discourse.org/t/trigger-a-zapier-task-with-discourse-webhooks/56753)。这可能会产生大量 Zapier 需要处理的请求，因此可能会很昂贵。

---

<div class="post-metadata">

**Author:** ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)\
**Post date:** [2023年七月25日 23:35 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/8 "2023-07-25T23:35:08Z")

</div>

> [@jordan-violet](#):
>
> 我想创建一个用户组，包含所有人，_除了_那些拥有例如 `@domain.com` 的用户。在 Discourse 中今天可以实现吗？

> [@jordan-violet](#):
>
> 再想想……这不仅会是一个很棒的功能，而且还可以根据 [数据探索器](https://meta.discourse.org/t/32566) 查询来创建动态用户组。

你如何处理不属于某个域/组的所有人？了解你将如何使用该组将充实此功能。🙂

> [@pfaffman](#):
>
> 所以你可以使用一些自动化工具来更新组，例如 [使用 Discourse Webhooks 触发 Zapier 任务](https://meta.discourse.org/t/trigger-a-zapier-task-with-discourse-webhooks/56753)。这可能会给 Zapier 带来大量请求，因此可能会很昂贵。

如果你要涉及 webhooks，我会将所有人添加到目标组，创建一个第二个_编程_组，并自动添加 `domain.com`，然后_仅_从第二个组触发用户事件的 webhooks，这会将这些帐户从_两个_组中移除。

我……花了很多时间预算 webhooks。😅

---

<div class="post-metadata">

**Author:** ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)\
**Post date:** [2023年七月26日 05:07 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/9 "2023-07-26T05:07:49Z")

</div>

> [@maiki](#):
>
> What do you do with everyone sans a domain/group? Knowing how you’d use that group will flesh out this feature.

My immediate use case was creating a user group of all users _minus_ employees.

---

<div class="post-metadata">

**Author:** ![ZeroDean](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zerodean/32/527869_2.png) [@ZeroDean](https://meta.discourse.org/u/ZeroDean)\
**Post date:** [2025年十一月13日 01:13 UTC](https://meta.discourse.org/t/ability-to-create-a-user-group-with-the-inverse-of-users-with-an-email-domain/272336/10 "2025-11-13T01:13:10Z")

</div>

> [@maiki](#):
>
> 你如何处理没有域/组的每个人？了解你将如何使用该组将充实此功能。🙂

我要求人们在介绍类别中进行自我介绍。每次他们这样做时，我都会将他们添加到一个组中。我想联系那些尚未介绍自己的人，并提醒他们这样做（这是一项要求）。

因此，“已有”组的反面……就是“未有”组。
