I wrote a plugin to enable hebrew characters in usernames. This is the full code:
add_filter ('sanitize_user', 'hu_sanitize_user', 10, 3);
//Overrides the Wordpress sanitize_user filter to allow hebrew letters and english letters only
function hu_sanitize_user ($username, $raw_username, $strict)
{
//Strip HTML Tags
$username = wp_strip_all_tags ($raw_username);
//Remove Accents
$username = remove_accents ($username);
//Kill octets
$username = preg_replace ('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);
//Kill entities
$username = preg_replace ('/&.+?;/', '', $username);
if ($strict){
//Replace
$username = preg_replace( '[\p{Hebrew}a-zA-Z]', '', $username );
}
//Remove Whitespaces
$username = trim ($username);
// Consolidate contiguous Whitespaces
$username = preg_replace ('|\s+|', ' ', $username);
return $username;
}
It works well, but the problem is that if the length of the username is more than 8 characters, it doesn't create a user in the users list. However, it does still send a confirmation email that the user was created - with the name and e-mail address missing from the message.
Any ideas what I'm doing wrong?