You can use the Custom Wizard Plugin to manage Discourse’s custom fields. The primary use case for this feature is managing custom fields for topics, posts, categories and groups created in wizard actions, but you could use it to manage custom fields for any purpose in Discourse.
What are “Custom Fields”?
In Discourse a “custom field” is a data store associated with a standard Discourse data model. For each of the Discourse data models there is an associated “custom_fields” table in the database where you can store data associated with a particular “row” (e.g. a particular topic or post) in the standard table. The custom field data is stored according to the “type” that is set for it.
Discourse models with custom fields
Custom field types
Custom Field Management
You can manage custom fields for all Discourse models, aside from user custom fields (see below), in the Custom Wizard Custom Field Admin UI.
All inputs you see above are required to register a field. We’ll go through each in turn
This is the Discourse model you want to associate your custom field with (see above)
This is the data type of the field (see above)
This is the name of your custom field. For computational purposes it will be transformed to a lowercase underscore separated string, for example “Peanut Butter” will become “peanut_butter”.
By default, any custom field you add to a Discourse model won’t be sent from the server to the client. Each custom field has to be explicitly “serialized” to the client in each context it is needed. The list of available serializers will change depending on what class you select.
The serializer names related to the names of the serializers in the code:
Topic View: This is the data sent when you’re looking at a topic
Topic List Item: This is the data sent with each list item on any topic list in Discourse.
Post: The data sent for every post
Category: This translates to the “BasicCategorySerializer” in the code.
User Custom Fields
You can manage user custom fields in the Customize > User Fields Admin UI. Any user fields you register there can be used in a Custom Wizard.
Custom Fields in Wizard Actions
You can add custom fields to any Topic, Post, Group or Category you create in a wizard action. For each relevant action you’ll see a “Custom” entry in the Actions section.
In the “map” entry for the custom field map you can change the selection type to “custom field” and you will see a list of the custom fields you have registered in the Custom Wizard’s Custom Field Admin UI.