# userCustomFields attr is undefined when extending the poster-name widget

**URL:** https://meta.discourse.org/t/usercustomfields-attr-is-undefined-when-extending-the-poster-name-widget/43398
**Category:** Development
**Created:** [April 28, 2016, 9:13pm UTC](https://meta.discourse.org/t/usercustomfields-attr-is-undefined-when-extending-the-poster-name-widget/43398 "2016-04-28T21:13:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [April 28, 2016, 9:13pm UTC](https://meta.discourse.org/t/usercustomfields-attr-is-undefined-when-extending-the-poster-name-widget/43398/1 "2016-04-28T21:13:53Z")

</div>

Continuing the discussion from [Getting joined data for widget scope](https://meta.discourse.org/t/getting-joined-data-for-widget-scope/42264/4):

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:

> [@Getting joined data for widget scope](https://meta.discourse.org/t/getting-joined-data-for-widget-scope/42264/3):
>
> The poster-name widget has access to the entire post as attrs.

and…

> [@Getting joined data for widget scope](https://meta.discourse.org/t/getting-joined-data-for-widget-scope/42264/3):
>
> Remember to make sure you whitelist the custom field if you want it accessible in your plugin

`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?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [April 28, 2016, 9:17pm UTC](https://meta.discourse.org/t/usercustomfields-attr-is-undefined-when-extending-the-poster-name-widget/43398/2 "2016-04-28T21:17:47Z")

</div>

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:

> <https://github.com/xfalcox/discourse-signatures/blob/master/plugin.rb#L20>

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [April 28, 2016, 9:25pm UTC](https://meta.discourse.org/t/usercustomfields-attr-is-undefined-when-extending-the-poster-name-widget/43398/3 "2016-04-28T21:25:32Z")

</div>

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.

> <https://github.com/discourse/discourse-user-notes/blob/550d5c73f4a4848352faeca6a07c0830ab7035b6/plugin.rb>

---

<div class="post-metadata">

### Author: ![daniyal](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@daniyal](https://meta.discourse.org/u/daniyal)
#### Post date: [January 29, 2022, 4:20pm UTC](https://meta.discourse.org/t/usercustomfields-attr-is-undefined-when-extending-the-poster-name-widget/43398/4 "2022-01-29T16:20:23Z")

</div>

Poster custom fields are empty when new post is created. Using allow\_public\_user\_custom\_field method to allow user fields.
