get_user_id_from_string( string $string )

This function has been deprecated. Use get_user_by() instead.

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

Description

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

See also

Parameters

$string

(string) (Required) Either an email address or a login.

Return

(int)

Source

File: wp-includes/ms-deprecated.php

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

Changelog

Version Description
3.6.0 Use get_user_by()
MU (3.0.0) Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_user_id_from_string