admin管理员组文章数量:1287514
I have some danish users that uses special chars like æøå and they can't log in to my wordpress blog. I tried on a fresh install on 4.2.2 and on 4.1.5 and it did not work, for example Andrew Schønnemann with a simple password and it did not work, got message ERROR: Invalid username. Lost your password?
. But with user Andrew Schonnemann
works fine, what could be the issue?
I have some danish users that uses special chars like æøå and they can't log in to my wordpress blog. I tried on a fresh install on 4.2.2 and on 4.1.5 and it did not work, for example Andrew Schønnemann with a simple password and it did not work, got message ERROR: Invalid username. Lost your password?
. But with user Andrew Schonnemann
works fine, what could be the issue?
2 Answers
Reset to default 2Are you creating your users via regular means or somehow importing them?
Trying to create such user WP prevents me from doing so:
ERROR: This username is invalid because it uses illegal characters. Please enter a valid username.
The reason for that is that username is validated with validate_username()
, which runs sanitize_user()
in strict mode. That reduces available characters to basic ASCII set.
In a nutshell WP doesn't consider that a valid username.
So the question is — is that actually a username in your case? Your users might be confusing Username with First/Last name fields, which are not used for login.
If you do want to support usernames like that you will have to override WP validation via hooks. That would probably take some serious testing to make sure it works properly and doesn't introduce security issues.
Found the answer, created the following function:
function wscu_sanitize_user ($username, $raw_username, $strict) {
$username = wp_strip_all_tags ($raw_username);
return $username;
}
add_filter ('sanitize_user', 'wscu_sanitize_user', 10, 3);
本文标签: phpWordpress 4 invalid username special charachters issue
版权声明:本文标题:php - Wordpress 4 invalid username special charachters issue 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741311254a2371660.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论