From a606f43156072c30ee52c4a25b4a410918201938 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 14 May 2009 18:55:32 +0000 Subject: [PATCH] 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: https://develop.svn.wordpress.org/trunk@11331 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/registration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/registration.php b/wp-includes/registration.php index 74f9f8bcb4..eba8773249 100644 --- a/wp-includes/registration.php +++ b/wp-includes/registration.php @@ -176,13 +176,13 @@ function wp_insert_user($userdata) { if ( empty($user_registered) ) $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) { $suffix = 2; while ($user_nicename_check) { $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++; } $user_nicename = $alt_user_nicename;