WordPress.org

Make WordPress Core

Changeset 14298


Ignore:
Timestamp:
04/29/10 16:05:33 (5 years ago)
Author:
donncha
Message:

Display the original username on the signup form on error, fixes #13124

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-functions.php

    r14226 r14298  
    457457    $errors = new WP_Error(); 
    458458 
     459    $orig_username = $user_name; 
    459460    $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); 
     461    $maybe = array(); 
     462    preg_match( '/[a-z0-9]+/', $user_name, $maybe ); 
     463 
     464    if ( $user_name != $orig_username || $user_name != $maybe[0] ) { 
     465        $errors->add( 'user_name', __( "Only the lowercase letters a-z and numbers allowed" ) ); 
     466        $user_name = $orig_username; 
     467    } 
     468 
    460469    $user_email = sanitize_email( $user_email ); 
    461470 
    462471    if ( empty( $user_name ) ) 
    463472        $errors->add('user_name', __('Please enter a username')); 
    464  
    465     $maybe = array(); 
    466     preg_match( '/[a-z0-9]+/', $user_name, $maybe ); 
    467  
    468     if ( $user_name != $maybe[0] ) 
    469         $errors->add('user_name', __('Only lowercase letters and numbers allowed')); 
    470473 
    471474    $illegal_names = get_site_option( 'illegal_names' ); 
     
    536539    } 
    537540 
    538     $result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors); 
     541    $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors); 
    539542 
    540543    return apply_filters('wpmu_validate_user_signup', $result); 
Note: See TracChangeset for help on using the changeset viewer.