On this page
get_user_by( string $field, int|string $value ): WP_User|false
Retrieves user info by a given field.
Parameters
$fieldstring Required-
The field to retrieve the user with. id | ID | slug | email | login.
$valueint|string Required-
A value for $field. A user ID, slug, email address, or login name.
Return
Source
File: wp-includes/pluggable.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_User::get_data_by() wp-includes/class-wp-user.php | Returns only the main user fields. |
| WP_User::__construct() wp-includes/class-wp-user.php | Constructor. |
Used By
| Used By | Description |
|---|---|
| wpmu_new_site_admin_notification() wp-includes/ms-functions.php | Notifies the Multisite network administrator that a new site was created. |
| wp_authenticate_application_password() wp-includes/user.php | Authenticates the user using an application password. |
| populate_network_meta() wp-admin/includes/schema.php | Creates WordPress network meta and sets the default values. |
| get_object_subtype() wp-includes/meta.php | Returns the object subtype for a given object ID of a specific type. |
| wp_create_user_request() wp-includes/user.php | Creates and logs a user request to perform a specific action. |
| 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_media_personal_data_exporter() wp-includes/media.php | Finds and exports attachments associated with an email address. |
| _wp_personal_data_handle_actions() wp-admin/includes/privacy-tools.php | Handle list table actions. |
| get_user_locale() wp-includes/l10n.php | Retrieves the locale of a user. |
| WP_REST_Users_Controller::create_item() wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php | Creates a single user. |
| WP_REST_Users_Controller::update_item() wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php | Updates a single user. |
| wp_authenticate_email_password() wp-includes/user.php | Authenticates a user using the email and password. |
| get_avatar_data() wp-includes/link-template.php | Retrieves default data about the avatar. |
| retrieve_password() wp-includes/user.php | Handles sending a password retrieval email to a user. |
| wp_validate_auth_cookie() wp-includes/pluggable.php | Validates authentication cookie. |
| get_userdata() wp-includes/pluggable.php | Retrieves user info by user ID. |
| get_profile() wp-includes/deprecated.php | Retrieve user data based on field. |
| WP_Query::get_queried_object() wp-includes/class-wp-query.php | Retrieves the currently queried object. |
| WP_Query::get_posts() wp-includes/class-wp-query.php | Retrieves an array of posts based on query variables. |
| check_password_reset_key() wp-includes/user.php | Retrieves a user row based on password reset key and login. |
| username_exists() wp-includes/user.php | Determines whether the given username exists. |
| email_exists() wp-includes/user.php | Determines whether the given email exists. |
| wp_authenticate_username_password() wp-includes/user.php | Authenticates a user, confirming the username and password are valid. |
| get_userdatabylogin() wp-includes/pluggable-deprecated.php | Retrieve user info by login name. |
| get_user_by_email() wp-includes/pluggable-deprecated.php | Retrieve user info by email. |
| wp_setcookie() wp-includes/pluggable-deprecated.php | Sets a cookie for a user who just logged in. This function is deprecated. |
| get_pages() wp-includes/post.php | Retrieves an array of pages (or hierarchical post type items). |
| is_user_spammy() wp-includes/ms-functions.php | Determines whether a user is marked as a spammer, based on user login. |
| wpmu_signup_blog_notification() wp-includes/ms-functions.php | 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() wp-includes/ms-functions.php | 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. |
| is_site_admin() wp-includes/ms-deprecated.php | Determine if user is a site admin. |
| get_user_details() wp-includes/ms-deprecated.php | Deprecated functionality to retrieve user information. |
| get_user_id_from_string() wp-includes/ms-deprecated.php | Get a numeric user ID from either an email address or a login. |
| check_comment() wp-includes/comment.php | Checks whether a comment passes internal checks to be allowed to add. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_user_by