wppaste
WordPress

get_user_by( string $field, int|string $value ): WP_User|false

Since
2.8.0, 4.4.0
Source
wp-includes/pluggable.php:101
Retrieves user info by a given field.

Parameters

$fieldstring
The field to retrieve the user with. id | ID | slug | email | login.
$valueint|string
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.

Uses · 2

Used by · 43

Show all 43

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

History

Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

4.4.0
Added 'ID' as an alias of 'id' for the $field parameter.from the docblock
2.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/pluggable.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.