WordPress.org

Make WordPress Core

Changeset 11331


Ignore:
Timestamp:
05/14/09 18:55:32 (6 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

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

    r11013 r11331  
    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)); 
     179    $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)); 
    180180 
    181181    if ($user_nicename_check) { 
     
    183183        while ($user_nicename_check) { 
    184184            $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)); 
     185            $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)); 
    186186            $suffix++; 
    187187        } 
Note: See TracChangeset for help on using the changeset viewer.