A WordPress-centric search engine for devs and theme authors



get_user_by ›

Since2.8.0
Deprecatedn/a
get_user_by ( $field, $value )
Parameters: (2)
  • (string) $field The field to retrieve the user with. id | ID | slug | email | login.
    Required: Yes
  • (int|string) $value A value for $field. A user ID, slug, email address, or login name.
    Required: Yes
Returns:
  • (WP_User|false) WP_User object on success, false on failure.
Defined at:
Codex:
Change Log:
  • 4.4.0

Retrieve user info by a given field



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;
	}
endif;

if ( ! function_exists( 'cache_users' ) ) :