我编写了一个插件来启用用户名中的希伯来文字符。以下是完整代码:
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;
}
它工作得很好,但问题是,如果用户名的长度超过8个字符,它不会在用户列表中创建用户。但是,它仍然会发送一封确认电子邮件,确认用户已创建,邮件中缺少名称和电子邮件地址。
知道我做错了什么吗?