Deprecate get_userdatabylogin() and get_user_by_email(). Props scribu. fixes #18333
git-svn-id: http://svn.automattic.com/wordpress/trunk@18513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f5a33890bb
commit
ec4ccf2900
|
@ -645,7 +645,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
|||
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
|
||||
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
|
||||
|
||||
$site_user = get_user_by_email( $email );
|
||||
$site_user = get_user_by( 'email', $email );
|
||||
if ( ! is_email( $email ) )
|
||||
$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );
|
||||
|
||||
|
|
|
@ -447,7 +447,7 @@ class WP_User {
|
|||
if ( ! empty( $id ) )
|
||||
$this->data = get_userdata( $id );
|
||||
else
|
||||
$this->data = get_userdatabylogin( $name );
|
||||
$this->data = get_user_by('login', $name );
|
||||
|
||||
if ( empty( $this->data->ID ) )
|
||||
return;
|
||||
|
|
|
@ -36,6 +36,40 @@ function set_current_user($id, $name = '') {
|
|||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('get_userdatabylogin') ) :
|
||||
/**
|
||||
* Retrieve user info by login name.
|
||||
*
|
||||
* @since 0.71
|
||||
* @deprecated 2.5
|
||||
* @deprecated Use get_user_by('login')
|
||||
*
|
||||
* @param string $user_login User's username
|
||||
* @return bool|object False on failure, User DB row object
|
||||
*/
|
||||
function get_userdatabylogin($user_login) {
|
||||
_deprecated_function( __FUNCTION__, '3.3', "get_user_by('login')" );
|
||||
return get_user_by('login', $user_login);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('get_user_by_email') ) :
|
||||
/**
|
||||
* Retrieve user info by email.
|
||||
*
|
||||
* @since 2.5
|
||||
* @deprecated 2.5
|
||||
* @deprecated Use get_user_by('email')
|
||||
*
|
||||
* @param string $email User's email address
|
||||
* @return bool|object False on failure, User DB row object
|
||||
*/
|
||||
function get_user_by_email($email) {
|
||||
_deprecated_function( __FUNCTION__, '3.3', "get_user_by('email')" );
|
||||
return get_user_by('email', $email);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('wp_setcookie') ) :
|
||||
/**
|
||||
* Sets a cookie for a user who just logged in. This function is deprecated.
|
||||
|
@ -54,7 +88,7 @@ if ( !function_exists('wp_setcookie') ) :
|
|||
*/
|
||||
function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
|
||||
_deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
|
||||
$user = get_userdatabylogin($username);
|
||||
$user = get_user_by('login', $username);
|
||||
wp_set_auth_cookie($user->ID, $remember);
|
||||
}
|
||||
else :
|
||||
|
@ -133,4 +167,4 @@ function wp_login($username, $password, $deprecated = '') {
|
|||
}
|
||||
else :
|
||||
_deprecated_function( 'wp_login', '2.5', 'wp_signon()' );
|
||||
endif;
|
||||
endif;
|
||||
|
|
|
@ -202,34 +202,6 @@ function get_user_by($field, $value) {
|
|||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('get_userdatabylogin') ) :
|
||||
/**
|
||||
* Retrieve user info by login name.
|
||||
*
|
||||
* @since 0.71
|
||||
*
|
||||
* @param string $user_login User's username
|
||||
* @return bool|object False on failure, User DB row object
|
||||
*/
|
||||
function get_userdatabylogin($user_login) {
|
||||
return get_user_by('login', $user_login);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('get_user_by_email') ) :
|
||||
/**
|
||||
* Retrieve user info by email.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @param string $email User's email address
|
||||
* @return bool|object False on failure, User DB row object
|
||||
*/
|
||||
function get_user_by_email($email) {
|
||||
return get_user_by('email', $email);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists( 'wp_mail' ) ) :
|
||||
/**
|
||||
* Send mail, similar to PHP's mail
|
||||
|
@ -594,7 +566,7 @@ function wp_validate_auth_cookie($cookie = '', $scheme = '') {
|
|||
return false;
|
||||
}
|
||||
|
||||
$user = get_userdatabylogin($username);
|
||||
$user = get_user_by('login', $username);
|
||||
if ( ! $user ) {
|
||||
do_action('auth_cookie_bad_username', $cookie_elements);
|
||||
return false;
|
||||
|
|
|
@ -3395,7 +3395,7 @@ function &get_pages($args = '') {
|
|||
foreach ( $post_authors as $post_author ) {
|
||||
//Do we have an author id or an author login?
|
||||
if ( 0 == intval($post_author) ) {
|
||||
$post_author = get_userdatabylogin($post_author);
|
||||
$post_author = get_user_by('login', $post_author);
|
||||
if ( empty($post_author) )
|
||||
continue;
|
||||
if ( empty($post_author->ID) )
|
||||
|
|
|
@ -1296,7 +1296,7 @@ function clean_user_cache($id) {
|
|||
* @return null|int The user's ID on success, and null on failure.
|
||||
*/
|
||||
function username_exists( $username ) {
|
||||
if ( $user = get_userdatabylogin( $username ) ) {
|
||||
if ( $user = get_user_by('login', $username ) ) {
|
||||
return $user->ID;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -1313,7 +1313,7 @@ function username_exists( $username ) {
|
|||
* @return bool|int The user's ID on success, and false on failure.
|
||||
*/
|
||||
function email_exists( $email ) {
|
||||
if ( $user = get_user_by_email($email) )
|
||||
if ( $user = get_user_by('email', $email) )
|
||||
return $user->ID;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -171,12 +171,12 @@ function retrieve_password() {
|
|||
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
|
||||
|
||||
if ( strpos($_POST['user_login'], '@') ) {
|
||||
$user_data = get_user_by_email(trim($_POST['user_login']));
|
||||
$user_data = get_user_by('email', trim($_POST['user_login']));
|
||||
if ( empty($user_data) )
|
||||
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
|
||||
} else {
|
||||
$login = trim($_POST['user_login']);
|
||||
$user_data = get_userdatabylogin($login);
|
||||
$user_data = get_user_by('login', $login);
|
||||
}
|
||||
|
||||
do_action('lostpassword_post');
|
||||
|
@ -544,7 +544,7 @@ default:
|
|||
// If the user wants ssl but the session is not ssl, force a secure cookie.
|
||||
if ( !empty($_POST['log']) && !force_ssl_admin() ) {
|
||||
$user_name = sanitize_user($_POST['log']);
|
||||
if ( $user = get_userdatabylogin($user_name) ) {
|
||||
if ( $user = get_user_by('login', $user_name) ) {
|
||||
if ( get_user_option('use_ssl', $user->ID) ) {
|
||||
$secure_cookie = true;
|
||||
force_ssl_admin(true);
|
||||
|
|
|
@ -113,7 +113,7 @@ for ( $i = 1; $i <= $count; $i++ ) {
|
|||
$author = sanitize_email($author);
|
||||
if ( is_email($author) ) {
|
||||
echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';
|
||||
$userdata = get_user_by_email($author);
|
||||
$userdata = get_user_by('email', $author);
|
||||
if ( empty($userdata) ) {
|
||||
$author_found = false;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue