Cybo Advanced Field EngineCyboweb Technologies · Documentation · v1.0.2

User field

Purpose

One or more users (an author, a teacher, a contact person) optionally limited to roles.

Field type name

user

Settings

Setting Description
Instructions Shown to editors below the field label. (max 2000 characters)
Roles Only offer users with one of these roles. Empty = every user.
Select Multiple Let editors choose more than one user; the value becomes a list.
Return Format array (ID, names, e-mail, URL, registered, description, avatar), object (WP_User) or id.
Translation How the field behaves in other languages: translate, copy, copy_once or do_not_translate. Used on top-level fields when WPML is active. See WPML.
Width Width on edit screens, to place fields side by side: 100 (full), 75, 66, 50, 33 or 25 (%). Phones always show full width.
Label per language The label and instructions per language code while editing in that language. Set on the Translation tab when WPML is active. See WPML.

PHP return value

By Return Format: an array like [ 'ID' => 3, 'display_name' => 'Eva', 'user_email' => … ], a WP_User, or the ID; null when empty; a list with Select Multiple.

Example

$contact = cafe_get_field( 'contact' ); // array

if ( $contact ) {
	echo esc_html( $contact['display_name'] );
}

Editing

A search box with a list that opens when it gets focus. The chosen items and the first 20 users are printed with the edit screen, so the list opens at once, with no request; when those 20 are all there is, typing filters them in the browser. Longer lists are searched on the server as the editor types (debounced, 20 per page, "Load more" for the next page) through GET /cafe/v1/references?field={key}&search=…&page=…, with a "Searching…" row while waiting. See REST.