Skip to content

REST API, Abilities and JavaScript ​

REST API ​

Reading ​

Groups with "Show in REST API" add an acf property to posts, terms and users in wp/v2.

  • By default, values are raw (IDs), typed as in ACF: numbers and booleans as such, attachment and object IDs as integers, empty ones as null.
  • With ?acf_format=standard, values are formatted but never leak private data:
    • relations include only posts the requester can read (ID, post_title, post_type, permalink);
    • users include ID and display_name, and their email only for those with list_users;
    • fields of password-protected posts are hidden.

Writing ​

http
POST /wp-json/wp/v2/posts/12
Content-Type: application/json

{ "acf": { "rating": 4, "steps": [ { "step": "One" } ] } }

Values are validated as in forms; unknown fields and invalid values return 400.

Internal routes ​

The wpff/v1/* routes (groups, options pages, post types, tools) are for administrators only.

Abilities API ​

On WordPress 6.9+, the plugin registers abilities in the custom-fields category. They are available through the wp-abilities/v1 REST routes and to MCP clients.

AbilityReturnsPermission
wpff/list-field-groupsField groups with their fields and location rules.Manage field groups.
wpff/get-field-valuesAn object's raw values. Input: { "object_id": 12 }, "term_5", "user_3" or "option".Edit the object.

Both abilities are read-only.

JavaScript: the wpff/fields store ​

On screens with fields, including the block editor:

js
const price = wp.data.select( 'wpff/fields' ).getFieldValue( 'price' );
wp.data.dispatch( 'wpff/fields' ).setFieldValue( 'price', 1500 );
wp.data.subscribe( () => console.log( wp.data.select( 'wpff/fields' ).getFieldValues() ) );

setFieldValue supports simple fields: text, number, choices, checkboxes, radios, true/false, dates, color and the visual editor.

Field types with their own scripts can start in newly added rows by listening for the wpff:init jQuery event on document. The event's argument is the new container.

GPL-2.0-or-later. Not affiliated with ACF or WP Engine.