Deprecate get_user_id_from_string() in favor of get_user_by( $field ) where $field is 'email' or 'login'. props SergeyBiryukov. fixes #23190.

git-svn-id: http://core.svn.wordpress.org/trunk@23438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-02-16 03:02:15 +00:00
parent 6bcd1665eb
commit 8252213fde
2 changed files with 37 additions and 35 deletions

View File

@ -270,3 +270,32 @@ function wpmu_admin_redirect_add_updated_param( $url = '' ) {
}
return $url;
}
/**
* 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.
*
* @since MU
* @deprecated 3.6.0
* @deprecated Use get_user_by()
* @uses get_user_by()
*
* @param string $string Either an email address or a login.
* @return int
*/
function get_user_id_from_string( $string ) {
_deprecated_function( __FUNCTION__, '3.6', '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;
}

View File

@ -908,7 +908,7 @@ function wpmu_create_user( $user_name, $password, $email ) {
return false;
$user = new WP_User( $user_id );
// Newly created users have no roles or caps until they are added to a blog.
delete_user_option( $user_id, $user->cap_key );
delete_user_option( $user_id, 'user_level' );
@ -1316,32 +1316,6 @@ function get_current_site() {
return $current_site;
}
/**
* Get a numeric user ID from either an email address or a login.
*
* @since MU
* @uses is_email()
*
* @param string $string
* @return int
*/
function get_user_id_from_string( $string ) {
$user_id = 0;
if ( is_email( $string ) ) {
$user = get_user_by('email', $string);
if ( $user )
$user_id = $user->ID;
} elseif ( is_numeric( $string ) ) {
$user_id = $string;
} else {
$user = get_user_by('login', $string);
if ( $user )
$user_id = $user->ID;
}
return $user_id;
}
/**
* Get a user's most recent post.
*
@ -1730,22 +1704,21 @@ function fix_phpmailer_messageid( $phpmailer ) {
}
/**
* Check to see whether a user is marked as a spammer, based on username
* Check to see whether a user is marked as a spammer, based on user login.
*
* @since MU
* @uses get_user_by()
*
* @param string $username
* @param string $user_login Optional. Defaults to current user.
* @return bool
*/
function is_user_spammy( $username = 0 ) {
if ( $username == 0 ) {
function is_user_spammy( $user_login = null ) {
if ( $user_login )
$user = get_user_by( 'login', $user_login );
else
$user = wp_get_current_user();
} else {
$user = get_user_by( 'login', $username );
}
return ( isset( $user->spam ) && $user->spam == 1 );
return $user && isset( $user->spam ) && 1 == $user->spam;
}
/**