Make user_nicenames unique. Props Denis-de-Bernardy. fixes #1626

git-svn-id: http://svn.automattic.com/wordpress/trunk@10997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-04-18 23:21:20 +00:00
parent 660013e30a
commit a6dd527f4e
1 changed files with 12 additions and 0 deletions

View File

@ -176,6 +176,18 @@ 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));
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));
$suffix++;
}
$user_nicename = $alt_user_nicename;
}
$data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
$data = stripslashes_deep( $data );