Allowing non-latin characters such as Japanese and Chinese in WordPress Registration

Default WordPress does not allow users to enter special characters in usernames. Non-latin characters are silently filtered out and your users cannot create accounts containing Chinese, Japanese or Korean letters.

For example, if Japanese character are entered in the unsername field, the following error message appears:

Japanese characters in username in WordPress registration

エラー: このユーザー名は使用できない文字を含んでいるため、無効です。有効なユーザー名を入力してください。

To allow users to use non-latin letters in the username field, you can use the following code:

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

Please add the above code to the functions.php file inn your WordPress theme's directory.

For your reference, The plugin "WordPress Special Characters in Usernames" allows users to enter special characters (Russian, Cyrillic, Arabic) in usernames.


Leave a Comment