Make WordPress Core

Changeset 10997


Ignore:
Timestamp:
04/18/2009 11:21:20 PM (16 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/registration.php

    r9699 r10997  
    177177        $user_registered = gmdate('Y-m-d H:i:s');
    178178
     179    $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));
     180
     181    if ($user_nicename_check) {
     182        $suffix = 2;
     183        while ($user_nicename_check) {
     184            $alt_user_nicename = $user_nicename . "-$suffix";
     185            $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));
     186            $suffix++;
     187        }
     188        $user_nicename = $alt_user_nicename;
     189    }
     190   
    179191    $data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
    180192    $data = stripslashes_deep( $data );
Note: See TracChangeset for help on using the changeset viewer.