Change login error messages

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

1

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

Leave a Comment