wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_user_by › WordPress Function

Seit2.8.0
Veraltetn/v
get_user_by ( $field, $value )
Parameter: (2)
  • (string) $field The field to retrieve the user with. id | ID | slug | email | login.
    Erforderlich: Ja
  • (int|string) $value A value for $field. A user ID, slug, email address, or login name.
    Erforderlich: Ja
Gibt zurück:
  • (WP_User|false) WP_User object on success, false on failure.
Definiert in:
Codex:
Changelog:
  • 4.4.0

Retrieves user info by a given field.



Quellcode

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' ) ) :
	/**
	 * Retrieves info for user lists to prevent multiple queries by get_userdata().
	 *
	 * @since 3.0.0
	 *
	 * @global wpdb $wpdb WordPress database abstraction object.
	 *
	 * @param int[] $user_ids User ID numbers list
	 */