# Discourse 自动化“通过用户自定义字段将用户添加到组”不起作用

**URL:** https://meta.discourse.org/t/discourse-automation-add-user-to-group-though-user-custom-field-not-working/333932
**Category:** Bug
**Tags:** automation
**Created:** [2024年十月31日 23:20 UTC](https://meta.discourse.org/t/discourse-automation-add-user-to-group-though-user-custom-field-not-working/333932 "2024-10-31T23:20:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Paul\_King](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paul_king/32/165426_2.png) [@Paul\_King](https://meta.discourse.org/u/Paul_King)
#### Post date: [2024年十月31日 23:20 UTC](https://meta.discourse.org/t/discourse-automation-add-user-to-group-though-user-custom-field-not-working/333932/1 "2024-10-31T23:20:32Z")

</div>

除非我遗漏了什么，否则 UI 中没有字段可以指定应将用户添加到哪个组。  
我想知道是否假定自定义用户字段和组具有相同的名称 - 但即使匹配这些名称，并将脚本设置为每分钟激活一次，也不会将用户添加到同名组中，这些用户在其用户配置文件中勾选了指定的自定义用户字段。

---

<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: [2024年十一月1日 00:23 UTC](https://meta.discourse.org/t/discourse-automation-add-user-to-group-though-user-custom-field-not-working/333932/2 "2024-11-01T00:23:03Z")

</div>

你照做了吗？请确保自定义用户设置为下拉列表，并且选项与您设置的名称匹配。

> [@Adding users to groups through custom field automation](https://meta.discourse.org/t/adding-users-to-groups-through-custom-field-automation/275873):
>
> bookmark This guide explains how to automatically add users to groups based on their selection of a user custom field during signup or profile update. person_raising_hand Required user level: Administrator Summary Create the necessary groups Set up a User Custom Field Create an automation to add users to groups Test the setup Creating the groups First, create the groups you want users to be automatically added to: Go to your site’s Admin area Navigate to Users \> Groups Click “New G…

---

<div class="post-metadata">

### Author: ![Paul\_King](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paul_king/32/165426_2.png) [@Paul\_King](https://meta.discourse.org/u/Paul_King)
#### Post date: [2024年十一月1日 03:32 UTC](https://meta.discourse.org/t/discourse-automation-add-user-to-group-though-user-custom-field-not-working/333932/3 "2024-11-01T03:32:53Z")

</div>

您好 @Lilly。在这种情况下，下拉选项不起作用，因为注册人需要能够加入一个或两个我设置的群组，所以我只使用了两个自定义用户字段，每个字段都有一个复选框来选择加入或退出该群组。

另外，重要的是，那些只被批准加入一个群组的人，一旦被批准，就无法自行加入或切换到另一个群组。
