# Accessing custom user fields via JavaScript/plugin API

**URL:** <https://meta.discourse.org/t/accessing-custom-user-fields-via-javascript-plugin-api/239035>\
**Category:** Development\
**Created:** [September 14, 2022, 9:21pm UTC](https://meta.discourse.org/t/accessing-custom-user-fields-via-javascript-plugin-api/239035 "2022-09-14T21:21:57Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Karpfen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/karpfen/32/261352_2.png) [@Karpfen](https://meta.discourse.org/u/Karpfen)\
**Post date:** [September 14, 2022, 9:21pm UTC](https://meta.discourse.org/t/accessing-custom-user-fields-via-javascript-plugin-api/239035/1 "2022-09-14T21:21:57Z")

</div>

Hello, I was trying to implement [Our solution for blurring NSFW content - #5 by bartv](https://meta.discourse.org/t/our-solution-for-blurring-nsfw-content/124584/5) - but unfortunately the code did not work anymore.  
I am kind of stuck here and i couldn’t find any documentation for the discourse JavaScript API in general or how to retrieve custom user fields.

I tried adding the linked code snippet to the header.html section in my site’s theme.  
The object accessible in JavaScript `const user = api.getCurrentUser();` seems to contain a property `custom_fields` not `user_fields` as it is in the referenced posting.

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/c/a/fca6013f5f32e19a44727f6ad5fae8016094adaf.png)

However it is empty, or i don’t know how to properly query/fill it. I’m getting the feeling i would need an actual Ruby plugin to access this data.

I would really appreciate any help on this issue, or guide how to specifically get the same functionality working again.  
The feature i need is adding a custom css-class to the body depending on a custom user field.

Thanks for reading o/

---

_[View the full topic](https://meta.discourse.org/t/accessing-custom-user-fields-via-javascript-plugin-api/239035)._
