get_user_by( string $field, int|string $value )
Retrieves user info by a given field.
Parameters
- $field
-
(Required) The field to retrieve the user with. id | ID | slug | email | login.
- $value
-
(Required) 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.
Source
File: wp-includes/pluggable.php
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-includes/class-wp-user.php: WP_User::get_data_by() |
Returns only the main user fields. |
wp-includes/class-wp-user.php: WP_User::__construct() |
Constructor. |
Used By
Used By | Description |
---|---|
wp-admin/includes/ajax-actions.php: wp_ajax_quick_edit_attachment() |
Ajax handler for updating attachment values and attributes. |
wp-admin/includes/schema.php: populate_network_meta() |
Creates WordPress network meta and sets the default values. |
wp-includes/user.php: wp_authenticate_application_password() |
Authenticates the user using an application password. |
wp-includes/ms-functions.php: wpmu_new_site_admin_notification() |
Notifies the Multisite network administrator that a new site was created. |
wp-includes/user.php: retrieve_password() |
Handles sending a password retrieval email to a user. |
wp-includes/deprecated.php: get_profile() |
Retrieve user data based on field. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::create_item() |
Creates a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::update_item() |
Updates a single user. |
wp-includes/l10n.php: get_user_locale() |
Retrieves the locale of a user. |
wp-includes/class-wp-query.php: WP_Query::get_queried_object() |
Retrieves the currently queried object. |
wp-includes/pluggable-deprecated.php: get_userdatabylogin() |
Retrieve user info by login name. |
wp-includes/pluggable-deprecated.php: get_user_by_email() |
Retrieve user info by email. |
wp-includes/pluggable-deprecated.php: wp_setcookie() |
Sets a cookie for a user who just logged in. This function is deprecated. |
wp-includes/class-wp-query.php: WP_Query::get_posts() |
Retrieves an array of posts based on query variables. |
wp-includes/pluggable.php: get_userdata() |
Retrieves user info by user ID. |
wp-includes/pluggable.php: wp_validate_auth_cookie() |
Validates authentication cookie. |
wp-includes/comment.php: check_comment() |
Checks whether a comment passes internal checks to be allowed to add. |
wp-includes/link-template.php: get_avatar_data() |
Retrieves default data about the avatar. |
wp-includes/ms-deprecated.php: get_user_id_from_string() |
Get a numeric user ID from either an email address or a login. |
wp-includes/ms-deprecated.php: is_site_admin() |
Determine if user is a site admin. |
wp-includes/ms-deprecated.php: get_user_details() |
Deprecated functionality to retrieve user information. |
wp-includes/meta.php: get_object_subtype() |
Returns the object subtype for a given object ID of a specific type. |
wp-includes/user.php: wp_user_personal_data_exporter() |
Finds and exports personal data associated with an email address from the user and user_meta table. |
wp-includes/user.php: wp_create_user_request() |
Creates and logs a user request to perform a specific action. |
wp-includes/user.php: check_password_reset_key() |
Retrieves a user row based on password reset key and login. |
wp-includes/user.php: username_exists() |
Determines whether the given username exists. |
wp-includes/user.php: email_exists() |
Determines whether the given email exists. |
wp-includes/user.php: wp_authenticate_username_password() |
Authenticates a user, confirming the username and password are valid. |
wp-includes/user.php: wp_authenticate_email_password() |
Authenticates a user using the email and password. |
wp-includes/post.php: get_pages() |
Retrieves an array of pages (or hierarchical post type items). |
wp-includes/ms-functions.php: is_user_spammy() |
Determines whether a user is marked as a spammer, based on user login. |
wp-includes/ms-functions.php: 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. |
wp-includes/ms-functions.php: 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. |
wp-admin/includes/privacy-tools.php: _wp_personal_data_handle_actions() |
Handle list table actions. |
Changelog
Version | Description |
---|---|
4.4.0 | Added 'ID' as an alias of 'id' for the $field parameter. |
2.8.0 | Introduced. |