get_user_id_from_string()WP 3.0.0

Deprecated from version 3.6.0. It is no longer supported and can be removed in future releases. Use get_user_by() instead.

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.

No Hooks.

Return

Int.

Usage

get_user_id_from_string( $email_or_login );
$email_or_login(string) (required)
Either an email address or a login.

Notes

Changelog

Since 3.0.0 Introduced.
Deprecated since 3.6.0 Use get_user_by()

get_user_id_from_string() code WP 6.5.4

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

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

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