The question:
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 _.[email protected]]|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 _.[email protected]]|i', '', $username );
Somehow i need to disable this section. But i am not sure how to do it.
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
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