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

get_user_id_from_string() WordPress Function

The get_user_id_from_string() function accepts a string parameter and returns the user ID of the user specified in the string. If no user is specified in the string, the function returns the current user's ID.

get_user_id_from_string( string $string ) #

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.

Top ↑

See also


Top ↑

Parameters

$string

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


Top ↑

Return

(int)


Top ↑

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


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Use get_user_by()
MU (3.0.0)Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.