WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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

share|improve this answer
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
Unknown username. Thank you. – p.a. Dec 16 '13 at 12:40
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
Thank you, this is great. – p.a. Dec 18 '13 at 7:35

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

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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