Ticket #1626: wp_check_nicename.diff
File wp_check_nicename.diff, 3.5 KB (added by , 18 years ago) |
---|
-
wp-login.php
212 212 require_once( ABSPATH . WPINC . '/registration.php'); 213 213 214 214 $user_login = sanitize_user( $_POST['user_login'] ); 215 $user_nicename = sanitize_title( $user_login ); 215 216 $user_email = apply_filters( 'user_registration_email', $_POST['user_email'] ); 216 217 217 218 // Check the username … … 220 221 elseif ( !validate_username( $user_login ) ) { 221 222 $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'); 222 223 $user_login = ''; 223 } elseif ( username_exists( $user_login ) )224 } elseif ( username_exists( $user_login ) || nicename_exists( $user_nicename ) ) { 224 225 $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); 226 } 225 227 226 228 // Check the e-mail address 227 229 if ($user_email == '') { -
wp-includes/pluggable.php
149 149 150 150 wp_cache_add($user->ID, $user, 'users'); 151 151 wp_cache_add($user->user_login, $user->ID, 'userlogins'); 152 wp_cache_add($user->user_nicename, $user->ID, 'usernicenames'); 152 153 return $user; 153 154 154 155 } 155 156 endif; 156 157 158 if ( !function_exists('get_userdatabynicename') ) : 159 function get_userdatabynicename($user_nicename) { 160 global $wpdb; 161 $user_nicename = sanitize_title( $user_nicename ); 162 163 $user_id = wp_cache_get($user_nicename, 'usernicenames'); 164 $userdata = wp_cache_get($user_id, 'users'); 165 166 if ( $data ) 167 return $user; 168 169 if ( empty( $user_nicename ) ) 170 return false; 171 172 if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_nicename = '$user_nicename'") ) 173 return false; 174 175 $wpdb->hide_errors(); 176 $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'"); 177 $wpdb->show_errors(); 178 179 if ($metavalues) { 180 foreach ( $metavalues as $meta ) { 181 $value = maybe_unserialize($meta->meta_value); 182 $user->{$meta->meta_key} = $value; 183 184 // We need to set user_level from meta, not row 185 if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) 186 $user->user_level = $meta->meta_value; 187 } 188 } 189 190 // For backwards compat. 191 if ( isset($user->first_name) ) 192 $user->user_firstname = $user->first_name; 193 if ( isset($user->last_name) ) 194 $user->user_lastname = $user->last_name; 195 if ( isset($user->description) ) 196 $user->user_description = $user->description; 197 198 wp_cache_add($user->ID, $user, 'users'); 199 wp_cache_add($user->user_login, $user->ID, 'userlogins'); 200 wp_cache_add($user->user_nicename, $user->ID, 'usernicenames'); 201 return $user; 202 203 } 204 endif; 205 157 206 if ( !function_exists('wp_mail') ) : 158 207 function wp_mail($to, $subject, $message, $headers = '') { 159 208 if( $headers == '' ) { -
wp-includes/registration.php
11 11 } 12 12 13 13 14 function nicename_exists( $nicename ) { 15 global $wpdb; 16 $nicename = sanitize_title( $nicename ); 17 $user = get_userdatabynicename( $nicename ); 18 if ( $user ) 19 return $user->ID; 20 21 return null; 22 } 23 24 14 25 function email_exists( $email ) { 15 26 global $wpdb; 16 27 $email = addslashes( $email ); … … 181 192 return wp_create_user($username, $password, $email); 182 193 } 183 194 184 ?> 185 No newline at end of file 195 ?>