Custom FieldsDeveloper Guide

How to Use UiChemy Custom Fields in Code: Functions, Hooks, and REST API

A practical developer guide with everything you need to work with UiChemy Custom Fields in PHP: read and save values, query posts, loop repeaters, and extend with hooks and the REST API.

Building a theme or plugin on top of UiChemy Custom Fields? Find the task you need below, copy the code, and change the field name. Every function, hook, and route is listed at the end in the Function Index.

ItemValue
VersionUiChemy 5.3.0, UiChemy Pro 5.3.0
RequiresPHP 7.4+, WordPress 6.9+
FunctionsStart with uich_
ClassesStart with Uich_Fields_
REST namespaceuichemy-fields/v1

Before You Start

Get Field Values

Use Each Field Type

Query Posts by Field Value

Values are saved as normal WordPress meta, so WP_Query, get_terms(), and get_users() can filter and sort by them. Build the meta key with uich_build_meta_key(), never by hand.

Repeater Fields (Pro)

On the free plan a repeater reads null and loops return no rows.

Save and Delete Values

Change How Values Load

Create and Read Definitions

Location Rules in Code

Groups of conditions: every condition in a group must match, any one group is enough.

'location_rules' => array(
    array(  // group 1
        array( 'param' => 'post_type', 'operator' => '==', 'value' => 'book' ),
    ),
    array(  // or group 2
        array( 'param' => 'post_type', 'operator' => '==', 'value' => 'page' ),
    ),
),

Field Type Reference

Hooks

REST API

Namespace uichemy-fields/v1. Every route needs manage_options. Cookie requests need the wp_rest nonce.

Migrate in Code

Imports definitions and values from ACF / SCF, Meta Box, Pods, and JetEngine.

Abilities and MCP

43 abilities (19 read, 24 write) let AI tools work with Custom Fields. Names start with uichemy/ and every write accepts dry_run.

Composer Integration

Function Index

Every function in the module, by task.

Free vs Pro for Developers

FeatureFreePro
Field types22 (plus legacy Password)Adds Relationship and Repeater
Location rule types516 more
Conditional logicNoYes
Field binding in the page builderNoCustom Field dynamic tags

On the Free Plan

  • Saving a group with a new Pro type, rule, or condition fails with HTTP 403.
  • For Pro types, uich_field_value() returns null and uich_save_field_value() returns false.
  • uich_field_values(), uich_field_values_raw(), uich_field_definitions(), and uich_get_all_field_data() aren't locked.
  • Downgrade-safe: Pro items already saved stay. Only new ones are refused.

How Pro Is Detected

  • uich_fields_is_pro(), which calls uichemy_is_pro().
  • The UiChemy Pro plugin (uichemy-pro) adds Uich_Pro_Fields_Location and Uich_Pro_Fields_Conditional.
  • Turning Pro on with the constant or uich_composer_is_pro filter without the Pro plugin leaves Conditional logic ignored and Pro rules matching nothing.

Security

Saving and Output

  • Always save through uich_save_field_value(). It checks permission and cleans the value for its type.
  • Escape on output. uich_print_field() and uich_print_repeater_value() escape. uich_field_value() doesn't.
  • WYSIWYG runs shortcodes for every visitor, the same trust level as post content.
  • The User field's default format includes email. Don't print it publicly.

Permissions

ActionNeeds
REST, import, storage routes, and definition savesmanage_options
Dashboard value savesEdit permission on the object plus a nonce
Abilitiesmanage_options plus a check per object

Exposure

  • Protect the definitions folder on Nginx or IIS. wp-content/uichemy-fields/ is only protected by .htaccess on Apache. Add a rule that denies it, or the JSON files can be downloaded.
  • Leave Show in REST off unless you need it. The REST path uses simpler cleaning.

What Isn't Available

  • No actions when a value loads, saves, or renders. Use the value filters.
  • No sanitize_value or escape_value filters, and no filters for field HTML, wrappers, classes, or labels.
  • No JavaScript API.
  • No custom field types.
  • No Gallery, Flexible Content, or Clone types.
  • No options page in the dashboard.
  • No shortcode for field values.
  • No import or export routes for definitions. Copy the files.
  • No per-field or per-group permissions.

Good to Know

  • Saving an unchanged number or True / False returns false.
  • Backslashes are removed from post, term, user, and comment values, including saves through uich_save_field_value(), not only the dashboard. Options keep them.
  • The "get all" functions skip the load filters. uich_field_values(), uich_field_values_raw(), uich_field_definitions(), and uich_get_all_field_data() don't run uich/pre_load_field or uich/load_field, and on the free plan they still return values from Pro field types. Use uich_field_value() for each field when your filters or the Pro check must apply.
  • Fields on Add New User aren't saved. Use user_form == register.
  • Export and import lose the description, the Active setting, and inactive groups.
  • Dates keep the format they were saved in.
  • Multisite: only user values include the site ID. Definitions are per site.
  • WPML: post, term, user, and comment values are copied once to new translations. Options aren't.
  • Uninstall removes field values, import backups, the journal, options, and the definition files only when Delete all data on uninstall is on (uichemy_settings). Posts and post type entries are never deleted.

If It Doesn't Work