Ticket #9568: 9568.7.diff
File 9568.7.diff, 9.2 KB (added by , 15 years ago) |
---|
-
wp-login.php
504 504 <?php if ( !isset($_GET['checkemail']) || !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?> 505 505 <form name="loginform" id="loginform" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post"> 506 506 <p> 507 <label><?php _e('Username ') ?><br />507 <label><?php _e('Username or Email') ?><br /> 508 508 <input type="text" name="log" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" tabindex="10" /></label> 509 509 </p> 510 510 <p> -
wp-includes/registration.php
119 119 $user_login = sanitize_user($user_login, true); 120 120 $user_login = apply_filters('pre_user_login', $user_login); 121 121 122 if ( empty($user_nicename) ) 123 $user_nicename = sanitize_title( $user_login ); 122 if ( empty($user_nicename) ) { 123 if ( $user_login == $user_email ) { 124 $user_nicename = preg_replace("/@.*/", '', $user_email); 125 } else { 126 $user_nicename = $user_login; 127 } 128 $user_nicename = sanitize_title( $user_nicename ); 129 } 124 130 $user_nicename = apply_filters('pre_user_nicename', $user_nicename); 125 131 126 132 if ( empty($user_url) ) … … 131 137 $user_email = ''; 132 138 $user_email = apply_filters('pre_user_email', $user_email); 133 139 134 if ( empty($display_name) ) 135 $display_name = $user_login; 140 if ( empty($display_name) ) { 141 $display_name = $user_login != $user_email ? $user_login : $user_nicename; 142 } 136 143 $display_name = apply_filters('pre_user_display_name', $display_name); 137 144 138 145 if ( empty($nickname) ) 139 $nickname = $user_login ;146 $nickname = $user_login != $user_email ? $user_login : $user_nicename; 140 147 $nickname = apply_filters('pre_user_nickname', $nickname); 141 148 142 149 if ( empty($first_name) ) … … 167 174 if ( empty($user_registered) ) 168 175 $user_registered = gmdate('Y-m-d H:i:s'); 169 176 170 $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)); 171 172 if ($user_nicename_check) { 173 $suffix = 2; 174 while ($user_nicename_check) { 175 $alt_user_nicename = $user_nicename . "-$suffix"; 176 $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)); 177 $suffix++; 178 } 179 $user_nicename = $alt_user_nicename; 180 } 181 182 $data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 177 $user_nicename = wp_unique_user_nicename($user_nicename, $ID); 178 179 $data = compact( 'user_login', 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 183 180 $data = stripslashes_deep( $data ); 184 181 185 182 if ( $update ) { 186 183 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) ); 187 184 $user_id = (int) $ID; 188 185 } else { 189 $wpdb->insert( $wpdb->users, $data + compact( 'user_login' ));186 $wpdb->insert( $wpdb->users, $data ); 190 187 $user_id = (int) $wpdb->insert_id; 191 188 } 192 189 … … 258 255 $userdata['user_pass'] = wp_hash_password($userdata['user_pass']); 259 256 } 260 257 258 // Keep trace of current user 259 $current_user = wp_get_current_user(); 260 261 261 // Merge old and new fields with new fields overwriting old ones. 262 262 $userdata = array_merge($user, $userdata); 263 263 $user_id = wp_insert_user($userdata); 264 264 265 // Update the cookies if the password changed. 266 $current_user = wp_get_current_user(); 265 // Update the cookies if the password or login changed. 267 266 if ( $current_user->id == $ID ) { 268 if ( isset($plaintext_pass) ) {267 if ( isset($plaintext_pass) || $user['user_login'] != $userdata['user_login'] ) { 269 268 wp_clear_auth_cookie(); 270 269 wp_set_auth_cookie($ID); 271 270 } … … 318 317 return apply_filters('user_contactmethods',$user_contactmethods); 319 318 } 320 319 321 ?> 320 /** 321 * Returns a unique nicename for a user 322 * 323 * @since 2.9 324 * @see wp_insert_user() 325 * 326 * @param string $user_nicename The user's nicename. 327 * @param string $user_id The user's ID. 328 * @return string The user's nicename. 329 */ 330 331 function wp_unique_user_nicename($user_nicename, $user_id) { 332 global $wpdb; 333 334 $user_id = (int) $user_id; 335 $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND ID != %d LIMIT 1" , $user_nicename, $user_id)); 336 337 if ( $user_nicename_check ) { 338 $suffix = 2; 339 while ( $user_nicename_check ) { 340 $alt_user_nicename = $user_nicename . "-$suffix"; 341 $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, $user_id)); 342 $suffix++; 343 } 344 $user_nicename = $alt_user_nicename; 345 } 346 347 return $user_nicename; 348 } 349 ?> 350 No newline at end of file -
wp-includes/user.php
84 84 } 85 85 86 86 $userdata = get_userdatabylogin($username); 87 87 88 if ( !$userdata ) 89 $userdata = get_user_by_email($username); 90 88 91 if ( !$userdata ) { 89 92 return new WP_Error('invalid_username', sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login'))); 90 93 } -
wp-admin/includes/user.php
131 131 $user->admin_color = 'fresh'; 132 132 133 133 $errors = new WP_Error(); 134 134 135 135 /* checking that username has been typed */ 136 if ( $user->user_login == '' ) 136 if ( !$update && empty($user->user_login) ) { 137 $user->user_login = $user->user_email; 138 } elseif ( $user->user_login == '' ) 137 139 $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' )); 138 140 139 141 /* checking the password has been typed twice */ … … 162 164 if (!empty ( $pass1 )) 163 165 $user->user_pass = $pass1; 164 166 165 if ( !$update && !validate_username( $user->user_login ) ) 166 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 167 if ( !validate_username( $user->user_login ) ) 168 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 169 if ( !$update && username_exists( $user->user_login ) ) 170 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); 167 171 168 if (!$update && username_exists( $user->user_login ))169 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ));170 171 172 /* checking e-mail address */ 172 173 if ( empty ( $user->user_email ) ) { 173 174 $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); -
wp-admin/user-new.php
92 92 $new_user_send_password = !$_POST || isset($_POST['send_password']); 93 93 ?> 94 94 <table class="form-table"> 95 <tr class="form-field form-required">96 <th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description">< ?php _e('(required)'); ?></span></label>95 <tr class="form-field"> 96 <th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"></span></label> 97 97 <input name="action" type="hidden" id="action" value="adduser" /></th> 98 <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr($new_user_login); ?>" aria-required="true"/></td>98 <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr($new_user_login); ?>" /></td> 99 99 </tr> 100 100 <tr class="form-field"> 101 101 <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th> -
wp-admin/user-edit.php
183 183 <h3><?php _e('Name') ?></h3> 184 184 185 185 <table class="form-table"> 186 <?php if ( $profileuser->user_login != $profileuser->user_email ) : ?> 186 187 <tr> 187 188 <th><label for="user_login"><?php _e('Username'); ?></label></th> 188 189 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Your username cannot be changed.'); ?></span></td> 189 190 </tr> 191 <?php else : ?> 192 <tr> 193 <th><label for="user_login"><?php _e('Username'); ?></label></th> 194 <td><input type="text" name="user_login" id="user_login" value="" class="regular-text" /> <span class="description"><?php _e('Your username cannot be changed once set.'); ?></span></td> 195 </tr> 196 <?php endif; ?> 190 197 191 198 <?php if ( !IS_PROFILE_PAGE ): ?> 192 199 <tr><th><label for="role"><?php _e('Role:') ?></label></th>