WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Function Reference/get user id from string"

m (Added description of what happens when a numeric value is sent to the function)
(http://core.trac.wordpress.org/ticket/23190)
Line 9: Line 9:
 
== Parameters ==
 
== Parameters ==
   
{{Parameter|$string|string||required}}
+
{{Parameter|$string|string|String representation of the user to lookup the ID for. May be either the user's login (their username), or the email address registered in WordPress. A numeric string is considered to be an existing user ID and is simply returned as such.|required}}
   
 
== Return Values ==
 
== Return Values ==
   
{{Return||int|}}
+
{{Return||int|ID of the user specified by $string on success, null if no user is found.}}
   
 
== Source File ==
 
== Source File ==

Revision as of 22:19, 13 January 2013

Description

Get a numeric user ID from either an email address or a login. If a number is sent to the function, that number is returned as the id.

Usage

<?php get_user_id_from_string$string ); ?>

Parameters

$string
(string) (required) String representation of the user to lookup the ID for. May be either the user's login (their username), or the email address registered in WordPress. A numeric string is considered to be an existing user ID and is simply returned as such.
Default: None

Return Values

(int) 
ID of the user specified by $string on success, null if no user is found.

Source File

get_user_id_from_string() is located in wp-includes/ms-functions.php