From 60b524160cbd0755985c36771c019ec9220f4629 Mon Sep 17 00:00:00 2001 From: ryan 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: http://svn.automattic.com/wordpress/trunk@11331 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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;