Fieldmanager_Datasource_User
class Fieldmanager_Datasource_User extends Fieldmanager_Datasource (View source)
Datasource to populate autocomplete and option fields with WordPress Users.
Properties
array | $options | The datasource options. |
from Fieldmanager_Datasource |
string | $options_callback | Options callback. |
from Fieldmanager_Datasource |
bool | $use_ajax | Allow Ajax. If set to false, Autocomplete will pre-load get_items() with no fragment, so False could cause performance problems. |
|
bool | $allow_optgroups | Allow option groups. |
from Fieldmanager_Datasource |
string | $ajax_action | The Ajax action. |
from Fieldmanager_Datasource |
static int | $counter | Counter to create uniquely named Ajax actions. |
from Fieldmanager_Datasource |
bool | $grouped | If true, group elements. |
from Fieldmanager_Datasource |
callable | $query_callback | Supply a function which returns a list of users; takes one argument, a possible fragment. |
|
array | $query_args | Arguments to get_users(), which uses WP's defaults. |
|
string | $display_property | Display property. Defaults to display_name, but can also be 'user_login', 'user_email', or 'user_nicename'. |
|
protected array | $allowed_display_properties | Allowed display properties for validation. |
|
string | $store_property | Store property. Defaults to ID, but can also be 'user_login', 'user_email', or 'user_nicename'. |
|
protected array | $allowed_store_properties | Allowed store properties for validation. |
|
string | $capability | Capability required to refer to a user via this datasource. |
|
string | $reciprocal | If not empty, set this object's ID as a value on the user. This is used to establish two-way relationships. |
Methods
Constructor. Used for validation.
Get a user by the specified field.
Get users which match this datasource, optionally filtered by a search fragment, e.g. for Autocomplete.
Get an action to register by hashing (non cryptographically for speed) the options that make this datasource unique.
Format items for use in Ajax.
Delete reciprocal user metadata prior to saving (presave will re-add).
Modify values before rendering editor.
Get view link for a user.
Get edit link for a user.
Sanitize the value based on store_property.
Details
__construct(array $options = array())
Constructor. Used for validation.
string
get_value(int $value)
Get a user by the specified field.
array
get_items(string $fragment = null)
Get users which match this datasource, optionally filtered by a search fragment, e.g. for Autocomplete.
string
get_ajax_action()
Get an action to register by hashing (non cryptographically for speed) the options that make this datasource unique.
get_items_for_ajax(string|null $fragment = null)
Format items for use in Ajax.
autocomplete_search()
Ajax callback to find posts.
string
presave_alter_values(Fieldmanager_Field $field, mixed $values, mixed $current_values)
Delete reciprocal user metadata prior to saving (presave will re-add).
Reciprocal relationships are not possible if we are not storing by ID.
array
preload_alter_values(Fieldmanager_Field $field, mixed $values)
Modify values before rendering editor.
string
presave(Fieldmanager_Field $field, mixed $value, mixed $current_value)
Handle reciprocal usermeta.
Reciprocal relationships are not possible if we are not storing by ID.
string
get_view_link(mixed $value)
Get view link for a user.
string
get_edit_link(int|string $value)
Get edit link for a user.
protected mixed
sanitize_value(mixed $value)
Sanitize the value based on store_property.