Un motore di ricerca WordPress per sviluppatori e autori di temi



get_user_id_from_string ›

Da3.0.0
Deprecato3.6.0
get_user_id_from_string ( $string )
Parametri:
  • (string) $string Either an email address or a login.
    Richiesto:
Vedi:
Ritorna:
  • (int)
Definito a:
Codex:
ChangeLog:
  • MU

Get a numeric user ID from either an email address or a login.

A numeric string is considered to be an existing user ID and is simply returned as such.



Sorgenti

function get_user_id_from_string( $string ) {
	_deprecated_function( __FUNCTION__, '3.6.0', 'get_user_by()' );

	if ( is_email( $string ) )
		$user = get_user_by( 'email', $string );
	elseif ( is_numeric( $string ) )
		return $string;
	else
		$user = get_user_by( 'login', $string );

	if ( $user )
		return $user->ID;
	return 0;
}