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:

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 _.<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b79af7">[email protected]</a>]|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 _.<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5d701d">[email protected]</a>]|i', '', $username );

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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);
}


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x