0

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 2

2

Are 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.

4
  • Thank you for you answer, so what hooks and an example function. The users are registering on the site, i am not creating or approving.
    – Adrian
    May 22, 2015 at 16:10
  • See the linked documentation. As per answer I probably would not recommend doing this at all, at least without testing and thoroughly looking into implications.
    – Rarst
    May 22, 2015 at 16:12
  • Does your site include any kind of custom registration process for that? If it's coded by third party it is clearly invalid to allow such usernames. And likely insecure!
    – Rarst
    May 22, 2015 at 16:13
  • It uses some bbpress functions, but don;t get it exactly how to make the function.
    – Adrian
    May 22, 2015 at 16:16
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.