Ticket #9568: 9568.diff
File 9568.diff, 7.6 KB (added by , 16 years ago) |
---|
-
wp-login.php
205 205 $user_email = apply_filters( 'user_registration_email', $user_email ); 206 206 207 207 // Check the username 208 if ( $user_login == '' )209 $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));210 elseif ( !validate_username( $user_login ) ) {211 $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));212 $user_login = '';213 } elseif ( username_exists( $user_login ) )214 $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));208 if ( !empty($user_login) ) { 209 if ( !validate_username( $user_login ) ) { 210 $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.')); 211 $user_login = ''; 212 } elseif ( username_exists( $user_login ) ) 213 $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.')); 214 } 215 215 216 216 // Check the e-mail address 217 217 if ($user_email == '') { … … 222 222 } elseif ( email_exists( $user_email ) ) 223 223 $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.')); 224 224 225 if ( !$errors->get_error_code() && empty($user_login) ) 226 $user_login = $user_email; 227 225 228 do_action('register_post', $user_login, $user_email, $errors); 226 229 227 230 $errors = apply_filters( 'registration_errors', $errors ); … … 373 376 374 377 <form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post"> 375 378 <p> 376 <label><?php _e('Username ') ?><br />379 <label><?php _e('Username (optional)') ?><br /> 377 380 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" tabindex="10" /></label> 378 381 </p> 379 382 <p> … … 466 469 <?php if ( !isset($_GET['checkemail']) || !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?> 467 470 <form name="loginform" id="loginform" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post"> 468 471 <p> 469 <label><?php _e('Username ') ?><br />472 <label><?php _e('Username or E-mail') ?><br /> 470 473 <input type="text" name="log" id="user_login" class="input" value="<?php echo $user_login; ?>" size="20" tabindex="10" /></label> 471 474 </p> 472 475 <p> -
wp-includes/registration.php
176 176 if ( empty($user_registered) ) 177 177 $user_registered = gmdate('Y-m-d H:i:s'); 178 178 179 $data = compact( 'user_ pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );179 $data = compact( 'user_login', 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 180 180 $data = stripslashes_deep( $data ); 181 181 182 182 if ( $update ) { 183 183 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) ); 184 184 $user_id = (int) $ID; 185 185 } else { 186 $wpdb->insert( $wpdb->users, $data + compact( 'user_login' ));186 $wpdb->insert( $wpdb->users, $data ); 187 187 $user_id = (int) $wpdb->insert_id; 188 188 } 189 189 … … 254 254 $userdata['user_pass'] = wp_hash_password($userdata['user_pass']); 255 255 } 256 256 257 // Keep trace of current user 258 $current_user = wp_get_current_user(); 259 257 260 // Merge old and new fields with new fields overwriting old ones. 258 261 $userdata = array_merge($user, $userdata); 259 262 $user_id = wp_insert_user($userdata); 260 263 261 264 // Update the cookies if the password changed. 262 $current_user = wp_get_current_user();263 265 if ( $current_user->id == $ID ) { 264 if ( isset($plaintext_pass) ) {266 if ( isset($plaintext_pass) || $user['user_login'] != $userdata['user_login'] ) { 265 267 wp_clear_auth_cookie(); 266 268 wp_set_auth_cookie($ID); 267 269 } -
wp-admin/includes/user.php
129 129 130 130 $errors = new WP_Error(); 131 131 132 /* checking that username has been typed */133 if ( $user->user_login == '' )134 $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ));135 136 132 /* checking the password has been typed twice */ 137 133 do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); 138 134 … … 159 155 if (!empty ( $pass1 )) 160 156 $user->user_pass = $pass1; 161 157 162 if ( !$update && !validate_username( $user->user_login ) ) 163 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 158 if ( !$update && !empty($user->user_login) ) { 159 if ( !validate_username( $user->user_login ) ) 160 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 161 if ( username_exists( $user->user_login ) ) 162 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); 163 } 164 164 165 if (!$update && username_exists( $user->user_login ))166 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ));167 168 165 /* checking e-mail address */ 169 166 if ( empty ( $user->user_email ) ) { 170 167 $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); … … 177 174 if ( $errors->get_error_codes() ) 178 175 return $errors; 179 176 177 if ( $update && $userdata->user_login == $userdata->user_email ) { 178 $user->user_login = $user->user_email; 179 } elseif ( !$update && empty($user->user_login) ) { 180 $user->user_login = $user->user_email; 181 } 182 180 183 if ( $update ) { 181 184 $user_id = wp_update_user( get_object_vars( $user )); 182 185 } else { -
wp-admin/user-new.php
89 89 } 90 90 ?> 91 91 <table class="form-table"> 92 <tr class="form-field form-required">93 <th scope="row"><label for="user_login"><?php _e('Username ( required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>94 <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true"/></td>92 <tr class="form-field"> 93 <th scope="row"><label for="user_login"><?php _e('Username (optional)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th> 94 <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" /></td> 95 95 </tr> 96 96 <tr class="form-field"> 97 97 <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th> -
wp-admin/user-edit.php
238 238 <h3><?php _e('Name') ?></h3> 239 239 240 240 <table class="form-table"> 241 <?php if ( $profileuser->user_login != $profileuser->user_email ) : ?> 241 242 <tr> 242 243 <th><label for="user_login"><?php _e('Username'); ?></label></th> 243 244 <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" class="regular-text" /> <?php _e('Your username cannot be changed.'); ?></td> 244 245 </tr> 245 246 <?php endif; ?> 246 247 <?php if ( !$is_profile_page ): ?> 247 248 <tr><th><label for="role"><?php _e('Role:') ?></label></th> 248 249 <td><select name="role" id="role">