Codex tools: Log in
Contents |
Returns the user ID of the user specified by either username or registered email address. In order to use this function in plugins, you must include the containing WordPress file using the following:
require_once(ABSPATH . WPINC . '/ms-functions.php');
<?php get_user_id_from_string( 'user@example.com' ); ?>
<?php
$useremail = 'user@example.com';
$userid = get_user_id_from_string( $useremail );
if ($userid !== null) {
echo 'User '.$useremail.' has the user ID of '.$userid;
} else {
echo 'User '.$useremail.' not found.';
}
?>