GCBGutenberg
Control Blocks
Buy

Structured fields

User profile fields

Reference, generated from the plugin source

User profile typed fields — wp_usermeta surface.

Same controls config shape as PostFields\Registrar. Public entry point in includes/User/helpers.php as gcblite_register_user_fields($config). Themes call it once; the fields appear on every user's profile page, stored to wp_usermeta keyed by user ID.

PHP
gcblite_register_user_fields([
    'page_title' => 'Profile extras',
    'controls' => [
        ['type' => 'image',    'attributeKey' => 'avatar_alt', 'label' => 'Custom avatar'],
        ['type' => 'url',      'attributeKey' => 'website',    'label' => 'Personal site'],
        ['type' => 'textarea', 'attributeKey' => 'extended_bio', 'label' => 'Long bio'],
    ],
]);

Unlike post-fields / options / taxonomy fields, user-meta is privacy-relevant. The REST route is auth-gated: only the user themself (or someone who may edit_user them) can read every field for a given user. Anyone else gets the fields marked "public": true and nothing more:

PHP
['type' => 'text', 'attributeKey' => 'role_title', 'label' => 'Role', 'public' => true],

What "public" covers:

  • A group / panel / tools-panel marked public makes its children
PHP
public (those whose parentPanelId is its id), unless a child says
`'public' => false`.
  • A public field its conditionalLogic hides, by the user's stored
PHP
values, is not returned: what the profile screen wouldn't show
isn't shown to anyone else.
  • A public repeater returns whole rows, unless a sub-field declares
PHP
`public` itself; then each row carries its `_id` and the sub-fields
marked `'public' => true`, no other:

  ['type' => 'repeater', 'attributeKey' => 'reviews', 'public' => true, 'fields' => [
      ['type' => 'textarea', 'attributeKey' => 'text',     'public' => true],
      ['type' => 'text',     'attributeKey' => 'reviewer', 'public' => true],
      ['type' => 'email',    'attributeKey' => 'reviewer_email'],
  ]],
  • Each public value passes through the
PHP
`gcblite_public_user_field_value` filter ($value, $control,
$user_id), so a plugin can drop rows (member reviews held for
moderation) or a field.

Who is shown at all: the route answers anyone else only for a user core's users endpoint shows them, one with published posts in a post type shown in REST; any other user gets the same 404 as one who doesn't exist, so the route can't be walked for user IDs. The gcblite_user_is_public filter ($is_public, $user_id) changes the rule (a marketplace whose members are public; members with listings already pass).

Functions

gcblite_register_user_fields()

PHP
gcblite_register_user_fields(array $config)

gcblite_get_user_fields()

PHP
gcblite_get_user_fields($user_id)

gcblite_get_public_user_fields()

PHP
gcblite_get_public_user_fields($user_id)