2
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?

2

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);
2
  • 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? 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. Dec 10 '10 at 12:48
-1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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