userCustomFields attr is undefined when extending the poster-name widget


(Steven Slade) #1

Continuing the discussion from Getting joined data for widget scope:

I am trying to extend the poster-name widget and add some user custom fields next to a user’s name on a post.

As per @eviltrout:

and…

whitelist_staff_user_custom_field("myCustomField") in plugin.rb :white_check_mark:

I have whitelisted the custom field I am trying to access but when I view attrs.userCustomFields of the poster-name widget it is undefined. Am I missing a step to make the user custom fields available to the widget/plugin?


(Rafael dos Santos Silva) #2

If things haven’t changed, you need to add user custom fields to the post serializer when you want a user custom field on the post object.

Like this:


(Steven Slade) #3

I was going off the Discourse Staff Notes plugin which uses the poster-name widget in a similar way I want to, and it doesn’t look like they do that.