How to translate wordpress error message

1

Hello, good morning! I am having a problem and I am not finding the variable to solve it, I have a site in WP and when I try to login and neither the password nor the email exists, I get the error message: ERROR: The username or password you entered is incorrect Lost your password? I tried to find this phrase in wp-login.php but I did not find it, could you help me? Note: I tried to use the loco translate but he does not think that phrase!

Edit the test I'm trying to make the messages appear only on the login page.

functions.php

function erroLogin(){
add_filter( 'login_errors', 'rs_custom_login_error' );
function rs_custom_login_error(){
    return $error = "Informações não existem ou estão erradas!";
}
}

page.php

<?php if ( is_page( 'login' ) ) { ?>
<?php erroLogin(); ?>
<?php } ?>

And I tried it that way too.

functions.php

<?php if ( is_page( 'login' ) ) { ?>
add_filter( 'login_errors', 'rs_custom_login_error' );
    function rs_custom_login_error(){
        return $error = "Informações não existem ou estão erradas!";
    }
}

But it still did not work

    
asked by anonymous 05.12.2017 / 11:53

3 answers

1

Search in your Theme the file functions.php then puts this snippet

add_filter( 'login_errors', 'rs_custom_login_error' );
/*
 * @desc    Filtro da mensagem de erro do admin do WP
 */
function rs_custom_login_error(){
    return $error = "Sua mensagem de erro vai aqui";
}

Here are some other snippets that you can use to customize this message. link

    
05.12.2017 / 15:04
1

Direct access to the administrator area. Access the functions.php as picture

ThenputthiscodeandanUpdateFile

add_filter('login_errors',create_function('$no_login_error','return"The user name and password is incorrect."'));

If it still does not work, paste this code into the file. The first is for the new message, and the second to hide the default message

function login_error_override()
{
    return 'The user name and password is incorrect.';
}
add_filter('login_errors', 'login_error_override');

add_filter('login_errors', create_function('$a', 'return null;'));

Reference source: link

    
05.12.2017 / 15:38
1

I was able to solve my problem, follow the code in case anyone needs this solution:

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 = "Um ou mais campo estão em branco ou dados não existem!";
        }
        return $error;
    }

Source where I located the response: link

    
06.12.2017 / 19:47