Changeset 34218 for trunk/src/wp-includes/user-functions.php
- Timestamp:
- 09/15/2015 10:13:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user-functions.php
r34116 r34218 1246 1246 $user_login = trim( $pre_user_login ); 1247 1247 1248 // user_login must be between 0 and 60 characters. 1248 1249 if ( empty( $user_login ) ) { 1249 1250 return new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.') ); 1250 } 1251 } elseif ( mb_strlen( $user_login ) > 60 ) { 1252 return new WP_Error( 'user_login_too_long', __( 'Username may not be longer than 60 characters.' ) ); 1253 } 1254 1251 1255 if ( ! $update && username_exists( $user_login ) ) { 1252 1256 return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) ); 1253 1257 } 1254 1258 1255 // If a nicename is provided, remove unsafe user characters before 1256 // using it. Otherwise build a nicename from the user_login. 1259 /* 1260 * If a nicename is provided, remove unsafe user characters before using it. 1261 * Otherwise build a nicename from the user_login. 1262 */ 1257 1263 if ( ! empty( $userdata['user_nicename'] ) ) { 1258 1264 $user_nicename = sanitize_user( $userdata['user_nicename'], true ); 1265 if ( mb_strlen( $user_nicename ) > 50 ) { 1266 return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) ); 1267 } 1259 1268 } else { 1260 $user_nicename = $user_login;1269 $user_nicename = mb_substr( $user_login, 0, 50 ); 1261 1270 } 1262 1271 … … 1396 1405 $suffix = 2; 1397 1406 while ($user_nicename_check) { 1398 $alt_user_nicename = $user_nicename . "-$suffix"; 1407 // user_nicename allows 50 chars. Subtract one for a hyphen, plus the length of the suffix. 1408 $base_length = 49 - mb_strlen( $suffix ); 1409 $alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix"; 1399 1410 $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)); 1400 1411 $suffix++;
Note: See TracChangeset
for help on using the changeset viewer.