get_user_by( string $field, int|string $value ): WP_User|false
- Since
- 2.8.0, 4.4.0
- Source
wp-includes/pluggable.php:101
Retrieves user info by a given field.
Parameters
$fieldstring- The field to retrieve the user with. id | ID | slug | email | login.
$valueint|string- A value for $field. A user ID, slug, email address, or login name.
Return
WP_User|false- WP_User object on success, false on failure.
Uses · 2
- WP_User::get_data_by()Returns only the main user fields.
- WP_User::__construct()Constructor.
Used by · 43
- WP_Automatic_Updater::send_debug_email()Prepares and sends an email of a full log of background update results, useful for debugging and geekery.
- WP_Automatic_Updater::send_email()Sends an email upon the completion or failure of a background core update.
- WP_Automatic_Updater::send_plugin_theme_email()Sends an email upon the completion or failure of a plugin or theme background update.
- WP_Query::get_posts()Retrieves an array of posts based on query variables.
- WP_Query::get_queried_object()Retrieves the currently queried object.
- WP_REST_Templates_Controller::get_wp_templates_author_text_field()Returns a human readable text for the author of the template.
- WP_REST_Users_Controller::create_item()Creates a single user.
- WP_REST_Users_Controller::update_item()Updates a single user.
- _wp_personal_data_handle_actions()Handle list table actions.
- check_comment()Checks whether a comment passes internal checks to be allowed to add.
- check_password_reset_key()Retrieves a user row based on password reset key and login.
- email_exists()Determines whether the given email exists.
Show all 43
- get_avatar_data()Retrieves default data about the avatar.
- get_object_subtype()Returns the object subtype for a given object ID of a specific type.
- get_pages()Retrieves an array of pages (or hierarchical post type items).
- get_profile()Retrieve user data based on field.
- get_user()Retrieves user info by user ID.
- get_user_by_email()Retrieve user info by email.
- get_user_details()Deprecated functionality to retrieve user information.
- get_user_id_from_string()Get a numeric user ID from either an email address or a login.
- get_user_locale()Retrieves the locale of a user.
- get_userdata()Retrieves user info by user ID.
- get_userdatabylogin()Retrieve user info by login name.
- is_site_admin()Determine if user is a site admin.
- is_user_spammy()Determines whether a user is marked as a spammer, based on user login.
- populate_network_meta()Creates WordPress network meta and sets the default values.
- retrieve_password()Handles sending a password retrieval email to a user.
- username_exists()Determines whether the given username exists.
- wp_authenticate_application_password()Authenticates the user using an application password.
- wp_authenticate_email_password()Authenticates a user using the email and password.
- wp_authenticate_username_password()Authenticates a user, confirming the username and password are valid.
- wp_create_user_request()Creates and logs a user request to perform a specific action.
- wp_media_personal_data_exporter()Finds and exports attachments associated with an email address.
- wp_new_user_notification()Emails login credentials to a newly-registered user.
- wp_notify_moderator()Notifies the moderator of the site about a new comment that is awaiting approval.
- wp_notify_postauthor()Notifies an author (and/or others) of a comment/trackback/pingback on a post.
- wp_password_change_notification()Notifies the blog admin of a user changing password, normally via email.
- wp_setcookie()Sets a cookie for a user who just logged in. This function is deprecated.
- wp_user_personal_data_exporter()Finds and exports personal data associated with an email address from the user and user_meta table.
- wp_validate_auth_cookie()Validates authentication cookie.
- wpmu_new_site_admin_notification()Notifies the Multisite network administrator that a new site was created.
- wpmu_signup_blog_notification()Sends a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked.
- wpmu_signup_user_notification()Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked.
Source
function get_user_by( $field, $value ) { $userdata = WP_User::get_data_by( $field, $value ); if ( ! $userdata ) { return false; } $user = new WP_User(); $user->init( $userdata ); return $user; }History
Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
4.4.0
Added 'ID' as an alias of 'id' for the
$field parameter.from the docblock2.8.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/pluggable.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.