function validate_username( $username ) {
    $sanitized = sanitize_user( $username, true );
    $valid = ( $sanitized == $username );

    return apply_filters( 'validate_username', $valid, $username );
}

in wp-includes/registration.php i want to change

$sanitized = sanitize_user( $username, true );

to

$sanitized = sanitize_user( $username, false );

I couldnt success to write add_filter in there, somehow its not working. Can you write a filter for this please?

link|improve this question

feedback

3 Answers

up vote 1 down vote accepted

Like so:

function my_validate_username( $valid, $username ) {
    $sanitized = sanitize_user( $username, false );
    $valid = ( $sanitized == $username );

    return $valid;
}

add_filter('validate_username', 'my_validate_username', 10, 2);
link|improve this answer
i am adding this change to core for turkish chars: core.trac.wordpress.org/ticket/15248 but when i use this add_filter i am getting error: Catchable fatal error: Object of class WP_Error could not be converted to string in wp-includes\formatting.php on line 2785 How can i fix this any idea? – Ünsal Korkmaz Dec 10 '10 at 12:20
Add some error checking in that case. The general idea is what is highlighted above: override the WP function entirely using the filter. – Denis Dec 10 '10 at 12:48
feedback

Overriding the filter does not work, it causes the error described by Ünsal. Has anybody actually got this working? Not sure how to trace, but it looks like the error is cause somewere in the registration process as a result of the non-latin username.

link|improve this answer
feedback

So the problem is caused by this line in wp-includes/user.php:

$user_login = sanitize_user($user_login, true);

which causes sanitize_true to be strict, which reduced to ascii.

Change to false to work around, who knows what other bugs this will cause since apparently non-latin logins in wordpress is not supported, see this thread:

http://bbpress.org/forums/topic/accents-in-username#post-19037

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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