In a development discussion about extending the poster-name widget to display user custom fields, stevenpslade reports that attrs.userCustomFields is undefined despite whitelisting the field via whitelist_staff_user_custom_field in plugin.rb. Falco suggests that user custom fields must also be added to the post serializer to be accessible on the post object, referencing an example plugin. stevenpslade counters by pointing to the Discourse Staff Notes plugin, which appears to achieve similar functionality without modifying the post serializer. daniyal adds that poster custom fields may be empty during new post creation and recommends using allow_public_user_custom_field to expose user fields. The core issue revolves around correctly exposing user custom fields to the widget scope, with conflicting evidence on whether post serializer modification is required. The discussion remains unresolved, highlighting potential gaps in documentation or inconsistent behavior between plugins.
whitelist_staff_user_custom_field("myCustomField") in plugin.rb
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?