Allowing non-latin characters in registration

I am from Turkey and we have “şŞçÇğĞüÜöÖıİ” characters in our alphabet.

I want to use those characters in permalinks/slugs/usernames. I found temporary solution for permalinks/slugs with core-hacking. There is no other option for it except core-hacking seems. You can find solution here:

Read More

http://core.trac.wordpress.org/ticket/15248

My problem is, user registration need a little fix after this one too. Fortunately there is filter i can use but couldnt handle it:

in wordpress includes/formatting.php :

function sanitize_user( $username, $strict = false ) {
 $raw_username = $username;
 $username = wp_strip_all_tags( $username );
 $username = remove_accents( $username );
 // Kill octets
 $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
 $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities

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

 $username = trim( $username );
 // Consolidate contiguous whitespace
 $username = preg_replace( '|s+|', ' ', $username );

 return apply_filters( 'sanitize_user', $username, $raw_username, $strict );
}

This section of code is producing error:

 if ( $strict )
  $username = preg_replace( '|[^a-z0-9 _.-@]|i', '', $username );

Somehow i need to disable this section. But i am not sure how to do it.

Related posts

Leave a Reply

1 comment

  1. Try this (not tested, I hope I am not short circuiting it into endless loop):

    add_filter('sanitize_user', 'non_strict_login', 10, 3);
    
    function non_strict_login( $username, $raw_username, $strict ) {
    
        if( !$strict )
            return $username;
    
        return sanitize_user(stripslashes($raw_username), false);
    }