Custom fields not populating in Discourse.User

(therealx) #1

I’ve added custom fields to my users, but the javascript object Discourse.User.Current.custom_field isn’t being populated with any of the values. Is this a bug, or an issue on my end?

Many thanks.

(Jens Maier) #2

Firstly, did you perhaps just typo? The current user should be Discourse.User.current(), not .Current.

Second, you must add your custom field to the SiteSetting.public_user_custom_fields list. It is a list of custom field names separated by | pipes. Custom fields included in that list are essentially public and will be revealed to all users. If you need the custom field to be private and, for instance, only visible to the account’s owner and admins, you need to monkey-patch UserSerializer#custom_fields in Ruby.

(Sam Saffron) #3

have a look at

for a proper usage sample.

(Jens Maier) #4

Oh, I didn’t realize there were several different user serializers. :slight_smile:


Necro posting as I’m having the same issues…even after registering my custom_field it is NOT available for use within the User or UserCard controller by doing Discourse.User.currentProp('custom_fields.my_field') any assistance would be greatly appreciated. Original request post here Change button depending on UserCustomField?