I want to translate the above message which appears on invalid username.

I know the answer is very similar to the one proposed here by I cannot find the exact handler.

Thank you.

1 Answer 1


In the en_GB version of the .mo translation file, this string is available:

<strong>ERROR</strong>: Invalid username. <a href=\"%s\" title=\"Password Lost and Found\">Lost your password</a>?

and the reference is from wp-includes/user.php on line 93. I found this using Poedit and searching using Ctrl + F.

From line 93 we get the following code:

return new WP_Error( 'invalid_username', sprintf( __( '<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?' ), wp_lostpassword_url() ) );

Which means you should write a function for your functions.php hooking into invalid_username like so:

add_filter( 'wp_login_errors', 'override_incorrect_username_message', 10, 2 );
function override_incorrect_username_message( $errors, $redirect_to ) {
    if( isset( $errors->errors['invalid_username'] ) ) {
        $errors->errors['invalid_username'][0] = 'Your new translated message';

    return $errors;

You can hunt around in wp-includes.php for other similar error messages which you can fix in a similar way.

  • many thanks for your answer, unfortunately it does nothing in my case.. I still search it, thank you.
    – p.a.
    Commented Dec 27, 2013 at 19:38
  • I also try to add the message in my theme's .mo file but to no avail.
    – p.a.
    Commented Dec 27, 2013 at 19:52
  • I found a typo in your answer. Correcting it above. It now works. Thanks a lot!
    – p.a.
    Commented Dec 27, 2013 at 20:17
  • Oops! Yeah. Thanks for that. An oversight on my part. Glad it works.
    – JMB
    Commented Dec 28, 2013 at 0:44

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.