Fieldmanager_Context_User
class Fieldmanager_Context_User extends Fieldmanager_Context_Storable (View source)
Use fieldmanager on the user profile screen and save data primarily to user meta.
Properties
Fieldmanager_Field | $fm | The base field associated with this context. |
from Fieldmanager_Context |
string | $uniqid | Unique ID of the form. Used for forms that are not built into WordPress. |
from Fieldmanager_Context |
array | $save_keys | Store the meta keys this field saves to, to catch naming conflicts. |
from Fieldmanager_Context |
array | $taxonomies_to_save | Taxonomies to save to. |
from Fieldmanager_Context_Storable |
string | $title | Group Title. |
Methods
Include a fresh nonce for this field in a response with refreshed nonces.
Check if the nonce is valid. Returns false if the nonce is missing and throws an exception if it's invalid. If all goes well, returns true.
Prepare the data for saving.
Walk group children to save when serialize_data => false.
Walk group children to load when serialize_data => false.
Meta and options are always stored as strings, so it's best to ensure
that scalar values get cast as strings to ensure that update_metadata()
and update_option()
are able to correctly compare the current value
against the previous value.
Get user meta.
Add user meta.
Update user meta.
Delete user meta.
Render the form on the user profile page.
Save user form.
Save data to user meta.
Details
__construct(string $title = '', Fieldmanager_Field $fm = null)
Add fieldmanager to user form.
protected string
nonce_key()
Get the nonce key for this field.
array
refresh_nonce(array $response)
Include a fresh nonce for this field in a response with refreshed nonces.
protected bool
is_valid_nonce()
Check if the nonce is valid. Returns false if the nonce is missing and throws an exception if it's invalid. If all goes well, returns true.
protected mixed
prepare_data(mixed $old_value = null, mixed $new_value = null, object $fm = null)
Prepare the data for saving.
protected string
render_field(array $args = array())
Render the field.
protected
save(mixed $data = null)
Handle saving data for any context.
protected
save_field(object $field, mixed $data)
Save a single field.
protected
save_walk_children(object $field, mixed $data)
Walk group children to save when serialize_data => false.
protected mixed
load()
Handle loading data for any context.
protected mixed
load_field(object $field)
Load a single field.
protected mixed
load_walk_children(object $field)
Walk group children to load when serialize_data => false.
static string|array
sanitize_scalar_value(mixed $value)
Meta and options are always stored as strings, so it's best to ensure
that scalar values get cast as strings to ensure that update_metadata()
and update_option()
are able to correctly compare the current value
against the previous value.
protected string|array
get_data(int $user_id, string $meta_key, bool $single = false)
Get user meta.
protected bool|int
add_data(int $user_id, string $meta_key, mixed $meta_value, bool $unique = false)
Add user meta.
protected mixed
update_data(int $user_id, string $meta_key, mixed $meta_value, mixed $data_prev_value = '')
Update user meta.
protected bool
delete_data(int $user_id, string $meta_key, mixed $meta_value = '')
Delete user meta.
mixed
legacy_presave_filter(mixed $data)
deprecated
deprecated
Maintain legacy support for custom filter.
render_user_form(WP_User $user)
Render the form on the user profile page.
save_user_form(int $user_id)
Save user form.
save_to_user_meta(int $user_id, array $data = null)
Save data to user meta.