Summery Summery
Retrieve user info by a given field
Syntax Syntax
Parameters 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 Return
(WP_User|false) WP_User object on success, false on failure.
Source 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;
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.4.0 | Added 'ID' as an alias of 'id' for the $field parameter. |
2.8.0 | Introduced. |