# 查找“通过 User Custom Field 添加用户到组”的 Userfield 自定义名称

**URL:** https://meta.discourse.org/t/finding-userfield-custom-name-for-add-user-to-group-through-user-custom-field/241608
**Category:** Support
**Tags:** automation, user-custom-fields
**Created:** [2022年十月8日 00:00 UTC](https://meta.discourse.org/t/finding-userfield-custom-name-for-add-user-to-group-through-user-custom-field/241608 "2022-10-08T00:00:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)
#### Post date: [2022年十月8日 00:13 UTC](https://meta.discourse.org/t/finding-userfield-custom-name-for-add-user-to-group-through-user-custom-field/241608/2 "2022-10-08T00:13:18Z")

</div>

你好安迪！

我们的一位托管客户最近也问了一个关于如何精确配置“通过用户自定义字段将用户添加到组”自动化脚本的问题。我在这里提供一个通用版本的答案，以惠及我们更广泛的生态系统，因为目前的 用户体验（UX）坦率地说并不友好——我们正在努力改进它，对此表示歉意。

### 如何设置“通过用户自定义字段将用户添加到组”自动化脚本

首先，您需要从“自定义”-\>“用户字段”（根据上述讨论，类型为下拉列表）创建用户字段，然后找出 **UserCustomField 名称** （而不是 UserField 名称，后者是字段的“模板”），并将自动化脚本指向该字段名称。

为了解开数据模型的相关部分：管理员 → 自定义 → 用户字段视图显示了 `UserField` 记录列表（即“用户字段模板”）。当您在此处创建记录时，用户随后可以在注册时或从其个人资料中选择该字段的值。该值将作为新的 `UserCustomField` 记录（即“用户字段实例”或“用户的实际用户字段”）存储，并链接到特定的用户 ID，而此记录又具有一个合成名称，构造为 `user_field_#{user_field_id}`。

也就是说，假设您的新 UserField 名称为 `Another UserField`：

 ![2022-09-27_17-07](https://global.discourse-cdn.com/meta/original/4X/c/e/a/ceadc7cf560f85030a8d5acb2ed359febd835082.png)

（您可以通过您网站的 `/admin/customize/user_fields.json` 查看此 JSON 视图）

查找 `name` 为您的 `UserField` 的记录，并观察其 ID，然后将其添加到 `user_field_NUMBER` 中以获取 UserCustomFields 将采用的 `name` 值，这就是您需要在脚本中的用户自定义字段值中配置的内容。

对于由此造成的混乱表示歉意；在改进用户体验之前，这些只是临时说明。

---

_[View the full topic](https://meta.discourse.org/t/finding-userfield-custom-name-for-add-user-to-group-through-user-custom-field/241608)._
