Function: get_user_by

get_user_by( string $field, integer | string $value )

Retrieve user info by a given field

Parameters

Name Type(s) Default Value Description
$field string

The field to retrieve the user with. id | ID | slug | email | login.

$value integer | string

A value for $field. A user ID, slug, email address, or login name.

Returns

WP_User | false

WP_User object on success, false on failure.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.