WP_Application_Passwords::get_user_application_passwords()wp-includes/class-wp-application-passwords.php | Gets a user’s application passwords.
|
wp_initialize_site()wp-includes/ms-site.php | Runs the initialization routine for a given site.
|
wp_default_packages_inline_scripts()wp-includes/script-loader.php | Adds inline scripts required for the WordPress JavaScript packages.
|
the_block_editor_meta_boxes()wp-admin/includes/post.php | Renders the meta boxes forms.
|
register_and_do_post_meta_boxes()wp-admin/includes/meta-boxes.php | Registers the default post meta boxes, and runs the do_meta_boxes actions.
|
wp_user_personal_data_exporter()wp-includes/user.php | Finds and exports personal data associated with an email address from the user and user_meta table.
|
WP_User::get_caps_data()wp-includes/class-wp-user.php | Gets the available user capabilities data.
|
WP_Widget_Text::render_control_template_scripts()wp-includes/widgets/class-wp-widget-text.php | Renders form template scripts.
|
WP_Screen::render_meta_boxes_preferences()wp-admin/includes/class-wp-screen.php | Renders the meta boxes preferences.
|
WP_User_Meta_Session_Tokens::get_sessions()wp-includes/class-wp-user-meta-session-tokens.php | Retrieves all sessions of the user.
|
choose_primary_blog()wp-admin/includes/ms.php | Handles the display of choosing a user’s primary site.
|
new_user_email_admin_notice()wp-includes/user.php | Adds an admin notice alerting the user to check for confirmation request email after email address change.
|
WP_Internal_Pointers::enqueue_scripts()wp-admin/includes/class-wp-internal-pointers.php | Initializes the new feature pointers.
|
wp_ajax_save_user_color_scheme()wp-admin/includes/ajax-actions.php | Handles auto-saving the selected color scheme for a user’s own profile via AJAX.
|
wp_ajax_dismiss_wp_pointer()wp-admin/includes/ajax-actions.php | Handles dismissing a WordPress pointer via AJAX.
|
WP_User::__get()wp-includes/class-wp-user.php | Magic method for accessing custom fields.
|
wp_update_user()wp-includes/user.php | Updates a user in the database.
|
get_blogs_of_user()wp-includes/user.php | Gets the sites a user belongs to.
|
is_user_member_of_blog()wp-includes/user.php | Finds out whether a user is a member of a given blog.
|
get_active_blog_for_user()wp-includes/ms-functions.php | Gets one of a user’s active blogs.
|
add_user_to_blog()wp-includes/ms-functions.php | Adds a user to a blog, along with specifying the user’s role.
|
remove_user_from_blog()wp-includes/ms-functions.php | Removes a user from a blog.
|
If the key does not exist the function will return an empty string or an empty array depending on the value of the $single parameter
false
if! is_numeric( $user_id )
or! absint( $user_id )
.Getting all meta data
This example demonstrates leaving the
$key
argument blank, in order to retrieve all meta data for the given user (in this example,user_id = 9
):Results:
Array ( [first_name] => Array ( [0] => Tom ) [last_name] => Array ( [0] => Auger)
[nickname] => Array ( [0] => tomauger ) [description] => etc.... )
Note: In order to access the data in this example you need to dereference the array that is returned for each key, like so:
To avoid this, you may want to run a simple
array_map()
on the results ofget_user_meta()
in order to take only the first index of each result (thus emulating what the$single
argument does when$key
is provided:Results:
Array ( [first_name] => Tom [last_name] => Auger [nickname] => tomauger [description] => etc.... )
Additionally, if you want to return ALL meta for a specific user and filter out empty values, you can run
array_filter()
on the results of thearray_map()
above:This example returns and then displays the last name for user id 9.
Result:
The last_name value for user id 9 is Franklin
Note: When doing
get_user_meta( $user_id );
without a meta key, the values are not unserialized automatically. You will need tomaybe_unserialize()
them.To check if returned value is empty, ie does not exist, you could use something like: