This guide explains how to create and configure custom user fields in Discourse, including how to add them to the signup form, user profiles, and user directory.
Required user level: Administrator
Custom user fields allow you to collect additional information from your users beyond the standard profile fields. These fields can be displayed on user cards, user summary pages, and even retrieved using the Data Explorer plugin. This guide will walk you through the process of creating and configuring custom user fields.
Adding a user field
Go to Admin > Community > User Fields (discourse.example.com/admin/config/user-fields).
If you haven’t created any user fields yet, you’ll see this screen:
Optional - Optional fields may be left empty by users
For all users - When a field is required by all users, every account, including logged on users will be forced to fill it. This is very useful for cases such as a terms-of-service (ToS) requirement.
On signup - All new account will be required to fill the field.
Additionally, at the bottom of the creation form, you’ll find these preference checkboxes:
Editable after signup: Allows users to update the field from their profile page
Show on public profile: Displays the field value on the user’s summary page
Show on user card: Shows the field value on the user card
Searchable: Enables searching for users based on this field’s value in the user directory
Show on signup form: Controls whether the field appears on the signup form. This is automatically enabled (and cannot be disabled) when the field requirement is “For all users” or “On signup”, or when the field is not editable after signup.
Show on public profile
When enabled, the field value will be shown on the user’s profile page:
Is there a setting I have to modify to specify the maximum length of a custom user field? Right now, in this “Test” field that I created as a test user field, I cannot enter even a single character on my user profile (or even “Test”, as shown).
구문은 custom.user_field_x여야 하며, 여기서 x는 /admin/config/user-fields/{x}/edit에 표시된 숫자 필드 ID입니다.
해당 매핑 기능은 Auth0 플러그인에서 직접 사용할 수 없습니다.
그럼에도 불구하고, 귀하가 설명하신 내용을 달성할 수 있는 몇 가지 옵션이 있습니다:
테마 컴포넌트 생성. 이미 Auth0에 저장된 값과 Discourse 사용자 정의 사용자 필드를 자동으로 동기화하는 작은 프론트엔드 스크립트를 추가할 수 있습니다. 예를 들어, 사용자가 로그인하고 해당 필드가 비어 있는 경우, 스크립트가 보안 엔드포인트(작은 클라우드 함수)를 호출하여 Auth0에서 필드 값을 가져오고 API를 통해 Discourse 프로필을 업데이트할 수 있습니다.
자동화 도구 사용. Discourse 외부에서 해당 동기화를 수행하기 위해 Zapier나 Make와 같은 외부 자동화 서비스를 사용할 수도 있습니다. 이 방식의 장점은 코드를 작성하거나 유지보수할 필요가 없고 제3자 서비스에 대한 비용만 지불하면 된다는 것입니다.
맞춤형 개발. Auth0 플러그인 자체를 확장하여 로그인 시 사용자 정의 클레임을 사용자 필드로 네이티브 매핑을 지원하도록 하거나, Auth0 플러그인과 함께 작동하는 맞춤형 플러그인을 구축할 수 있습니다.
테마 컴포넌트 방식의 명확한 단점은 사용자 정의 코드를 직접 작성하고 유지보수해야 하며, 잠재적인 버그나 취약점을 도입하지 않도록 보안 측면에서도 주의를 기울여야 한다는 점입니다. 솔직히 말하면, 귀하와 같은 프로덕션 사이트에는 권장하지 않는 솔루션입니다.
저라면 두 번째 옵션인 제3자 도구 사용, 또는 Auth0 플러그인 자체를 강화하기 위한 기능 요청 또는 맞춤형 작업 요청(프로젝트 매니저들의 평가에 따라)을 고려하는 쪽에 더 무게를 둘 것입니다.
사용자 필드 목록 개요에서 가입 양식에 있는 필수 필드(예: Je suis… Pays)와 선택 필드(예: Mes attentes)를 어떻게 구분하는지 확인이 안 됩니다. 제가 뭘 놓치고 있는 건지, 아니면 이 부분이 누락된 건지 궁금합니다. 선택 필드인지 확인하려면 필드를 편집해야 하니 상당히 번거롭습니다. (이것이 적절한 장소인지 확실하지 않아서 어디에 올려야 할지 몰랐습니다.)