Use user_login instead of ID to check if user exists when creating unique nicenames. ID isn't available when inserting new users. Props sivel. see #9393
git-svn-id: http://svn.automattic.com/wordpress/trunk@11331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fc488172cc
commit
60b524160c
|
@ -176,13 +176,13 @@ function wp_insert_user($userdata) {
|
||||||
if ( empty($user_registered) )
|
if ( empty($user_registered) )
|
||||||
$user_registered = gmdate('Y-m-d H:i:s');
|
$user_registered = gmdate('Y-m-d H:i:s');
|
||||||
|
|
||||||
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND ID != %d LIMIT 1" , $user_nicename, (int) $ID));
|
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
|
||||||
|
|
||||||
if ($user_nicename_check) {
|
if ($user_nicename_check) {
|
||||||
$suffix = 2;
|
$suffix = 2;
|
||||||
while ($user_nicename_check) {
|
while ($user_nicename_check) {
|
||||||
$alt_user_nicename = $user_nicename . "-$suffix";
|
$alt_user_nicename = $user_nicename . "-$suffix";
|
||||||
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND ID != %d LIMIT 1" , $alt_user_nicename, (int) $ID));
|
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login));
|
||||||
$suffix++;
|
$suffix++;
|
||||||
}
|
}
|
||||||
$user_nicename = $alt_user_nicename;
|
$user_nicename = $alt_user_nicename;
|
||||||
|
|
Loading…
Reference in New Issue