Are custom_fields on posts/topics available via the API?


I see from some digging that a custom_fields property exists on posts/topics and plugins make extensive use of it.

Is this field available through the API? Can it be set? Can it be queried against? Could a search be made for a topic with a certain value for a custom field?


I have this exact same question. All the dialogue I see is about custom fields for users, not a general discussion :confused:

(Rafael dos Santos Silva) #3

Custom Fields are possible for topics, categories, users and posts.

Users are the common case, and can be created from the Admin UI and filled in user preferences.

All types can be handled in plugins, created, modified and read.

Using a custom field would be:

  • Creating the field in the plugin.rb
  • Adding it to some serializer so it’s avaliable for the front-end code
  • Using it in a handlebars template

Many plugins use this fields like:


@Falco thank you for the clarification. I will look to these plugins as examples.

I finally found what I was looking for… register_custom_field_type(). Prior to seeing this, I was rather confused on how the database handled the type information. Well, now I know :smiley:

(Ellen Badgley) #5

@Falco a belated thanks for the link to the Signatures plugin. Not only do I wholeheartedly approve of old-style forum signatures, but it’s a great example of putting user custom fields to work for this new Discourse developer.