get_user_by() – Retrieves user info by a given field.

You appear to be a bot. Output may be restricted

Description

Retrieves user info by a given field.

Usage

$WP_User|false = get_user_by( $field, $value );

Parameters

$field
( string ) required

$value
( int|string ) required – 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.

Source

File name: wordpress/wp-includes/pluggable.php


Lines:

1 to 13 of 13
  function get_user_by( $field, $value ) {
    $userdata = WP_User::WP_User::get_data_by( $field, $value );

    if ( ! $userdata ) {
      return false;
    }

    $user = new WP_User;
    $user->init( $userdata );

    return $user;
  }
 

 View on GitHub View on Trac

Published:

Last updated:

31st October 2022

Information

API Letters: ,,

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