Adding non-visible User Custom Fields to the API

This is a quick walkthrough on how to use the public user custom fields or staff user custom fields admin setting to expose User Custom Field data through the API without displaying it on a user card.

First, create your User Custom Field. You can find out more detail about that in Create and configure custom user fields

Here’s mine:

Once you have that set up and saved, you can now visit the user fields json at /admin/customize/user_fields.json to find out the ID number:

user_fields json

This can now be entered into either the public user custom fields or staff user custom fields admin setting. The first would be accessible to all, and the second only to a staff API key. The format you need is user_field_X - in my case user_field_7:

As mine is in staff user custom fields it will only be visible to a staff API key.

This will now be included in the /u/[USER].json under ‘User Fields’:

user fields - user json

And there you go. :slight_smile:

4 Likes