Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

took a look at the questions but I couldn`t find a similar one.

I need to change the custom error messages that are displayed when user tries to login with a wrong username or password.

Like, change this: "ERROR: The password you entered for the username %1$s is incorrect. Lost your password?" to this "Wrong information" (just an example)

I tried to use the "add_filter" but I`m not familiar with it, so, any help will be appreciated! Thanks

share|improve this question
1  
I've found a very specific solution sutanaryan.com/wordpress/… –  user20986 Sep 30 '12 at 6:18
add comment

1 Answer 1

up vote 8 down vote accepted

you can do that using login_errors filter hook and here is how:

add_filter('login_errors','login_error_message');

function login_error_message($error){
    //check if that's the error you are looking for
    $pos = strpos($error, 'incorrect');
    if (is_int($pos)) {
        //its the right error so you can overwrite it
        $error = "Wrong information";
    }
    return $error;
}

update:

i just tested the code and it works fine just pasted the code in my theme's functions.php file without changing anything with the .po file

enter image description here

share|improve this answer
    
Just to make everything clear, I should replace 'incorrect' with the error string? By the way, thanks for your answer! –  Vitor Argos Aug 5 '11 at 22:07
    
Just tried this way and it doesn`t work, but I`m not sure if the wordpress .po file is overwriting the text. Any ideas? –  Vitor Argos Aug 5 '11 at 22:10
    
the text from WordPress.po is served before that filter hook is fired, and no you don't have to change incorrect, its checking if the error message contains that word. –  Bainternet Aug 5 '11 at 22:15
    
I tried to put this to work but I couldn`t. I actually even tried to remove the conditional part, so it should return the text in the $error variable right? But it has no effect. Digging the .po file I saw that the messages I want to overwrite are located in the wp-includes/user.php file like: "<strong>ERROR</strong>: The username field is empty." –  Vitor Argos Aug 5 '11 at 22:37
    
@Vitor you are doing something wrong, there is no need to touch the .po file, i updated my answer. –  Bainternet Aug 6 '11 at 0:03
show 2 more comments

Your Answer

 
discard

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.