This guide explains how to expose user custom field data through the API without displaying it on a user card.
Required user level: Administrator
This guide will walk you through the process of making User Custom Field data accessible via the API without displaying it on a user card. This can be useful when you need to programmatically access custom user data while keeping it hidden from general view.
Creating a User Custom Field
- First, create your User Custom Field. For detailed instructions, refer to the guide for creating and configuring custom user fields guide.
- Once you’ve set up your custom field, save it.
Finding the User Custom Field ID
- Navigate to
/admin/config/user-fields.jsonin your browser. - Locate your newly created custom field and note its ID number.
Configuring API Access
- Go to your site’s admin settings.
- Find either the
public user custom fieldsorstaff user custom fieldssetting:- Use
public user custom fieldsif you want the data to be accessible to all API users. - Use
staff user custom fieldsif you want to restrict access to staff API keys only.
- Use
- Enter the custom field in the format
user_field_X, where X is the ID number you noted earlier.
For example, if your custom field ID is 7, you would enteruser_field_7.
Accessing the Custom Field Data
Once configured, the custom field data will be included in the /u/[USERNAME].json endpoint under the “User Fields” section.
Searching Users by Custom Field Values
You can search for users based on their custom field values using the API:
- Ensure the custom field has the “searchable” option checked in its settings.
- Use the
/directory_items.jsonendpoint with your query parameters.
Here’s an example API call:
https://yourdomain.com/directory_items.json?period=weekly&order=likes_received&name=SearchTerm&user_field_ids=1|2
-
user_field_ids: Specify which custom fields to search (e.g.,user_field_ids=5to search only in custom field ID 5). -
name: The search term to look for in custom fields, usernames, and possibly full names.
Note: This search is not exclusive to custom fields and may return results based on username or full name matches as well.
For more details on available parameters, consult the API documentation.
Additional Resources
Last edited by @MarkDoerr 2025-03-28T01:41:22Z
Last checked by @hugh 2024-07-09T11:12:48Z
Check document
Perform check on document:




