Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I can see validate_user() calls sanitize_user() with strict argument as true, which means uppercase letters are not allowed too.

In source code, I found this comment

// If strict, reduce to ASCII for max portability.
    if ( $strict )
        $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );

I would like to know how does this affect portability?

share|improve this question
    
The i modifier in the regex pattern makes it case-insensitive, just something to note. –  t31os Apr 8 '11 at 14:58
    
so what does this regex actually do here? –  Ashfame Apr 9 '11 at 19:56
1  
Replaces anything not a-z(upper or lower), 0-9(ie. any number), an underscore, period, hyphen or an @ symbol.. –  t31os Apr 9 '11 at 23:21
    
so how does it block the uppercase alphabets then? :S –  Ashfame Apr 10 '11 at 14:25
1  
@Ashfame: actually, the function doesn't block uppercase letters. In the comment above the functions, WP writes: "If $strict is true, only alphanumeric characters (as well as _, space, ., -, * @) are returned.". That means uppercase letter are accepted. In fact, I have a WP where I have the username with uppercase letter, and no problems at all. –  Rilwis Jun 7 '11 at 13:44

3 Answers 3

up vote 5 down vote accepted

Uppercase characters are not blocked in usernames on single site setups.

Uppercase characters ARE blocked in usernames on multisite setups. The wpmu_validate_user_signup function forces lowercase a-z and numbers 0-9 only.

share|improve this answer

If You are not allowing users to register site, you may disable 'uppercase' restriction from MS install, just add into your theme functions.php file:

remove_action( 'sanitize_user', 'strtolower' );
share|improve this answer

Off hand, I suppose it would be so you can use validate_user's results in a URL or a $_GET string. I'm sure there are plenty of other reasons as well, I guess I don't know what they mean by max portability...

share|improve this answer
    
yes, I am interested in knowing about how this affects portability. anything else like a variable from URL can be configured to converted to lowercase and then made it work. A bit extra work, but will work. –  Ashfame Apr 8 '11 at 12:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.