I try to translate the "wrong password" response at system log in.

I update wp-login.php, however I do not find there any handler for wrong password, wrong user.

Maybe such generic tests are handled somewhere else?

Thank you.


We can also use the filter wp_login_errors available in wp-login.php to do the above. Using the same filter you can customize other error messages too like registration, checkmail etc.

Use the below code in the active theme's functions.php file

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

    return $errors;

And if you want to get hold of the username at this time you can do that by using another hook ie: wp_login_failed

add_action( 'wp_login_failed', 'wpse_end_login_fail' );
function wpse_end_login_fail( $username ) {

echo $username;
// Go on with what you want to do with the login failed username


The above will give you the username

You can see the above set of codes in action in the below image. You can see the username we got using the hook in the top left corner of the image/screenshot

enter image description here

  • Thank you. I assume a relavant handler is due in the case of "unknown user"? – p.a. Dec 16 '13 at 11:33
  • Can you explain what you mean by unknown user? – Maruti Mohanty Dec 16 '13 at 11:39
  • Whats your requirement here, wasn't it to customize the wordpress incorrect password message? Wordpress checks if username and password matches else the message. Do you want to point out if the username is invalid itself!! – Maruti Mohanty Dec 16 '13 at 12:44
  • Yes, exactly; I want to trap the handler of inexistent username. – p.a. Dec 16 '13 at 14:46
  • @p.a. I have edited the answer, now with the second function you can get the username when the login fails ie:the username is correct but the password is incorrect. – Maruti Mohanty Dec 16 '13 at 15:25

The text comes from wp_authenticate_username_password() in wp-includes/user.php. There is no other filter than gettext. So this works:

add_filter( 'gettext', function( $translation, $text, $domain )
    if ( 'default' !== $domain )
        return $translation;

    if ( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?' !== $text )
        return $translation;

    return 'Custom password message';
}, 10, 3 );

screen shot

  • Thank you. I assume a relavant handler is due in the case of "unknown user"? – p.a. Dec 16 '13 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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