How to translate wordpress error message

Asked

Viewed 735 times

1

Hello, good morning, good morning! I have a problem and I am not finding the variable to be able to solve, I have a site in WP and when you try to login and neither the password nor the email exist returns me the error message: ERROR: The username or password you entered is incorrect. Lost your password? I tried to locate this phrase in wp-login.php but I didn’t find it there, could you help me? Note: I tried to use the loco Translate but he does not find this phrase!

Test edit 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 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 hasn’t worked yet

3 answers

1

I managed to solve my problem, follow the code in case someone 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 answer: https://wordpress.stackexchange.com/questions/25099/change-login-error-messages

1

  • I tried but it didn’t work keep returning the same message.

  • https://snag.gy/pI9xeZ.jpg

  • @Fernando edited my answer now with another script tries there now

  • I managed however I realized that this happening a bug, this error message is appearing even in the registration page, I wanted it to stay only for the login page, I tried in some ways it did not work very well I will pass the below the way I am trying

  • @Fernando the same platform of Stackoverflow has a system only for doubts in Wordpress https://wordpress.stackexchange.com/ Try to post your question in English there you will have more specialized help.

  • Thanks I didn’t know, I’ll try there too!

Show 1 more comment

1

Direct option by administrator area. Access functions.php as per image inserir a descrição da imagem aqui

Then put this code and an Update File

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

If it still doesn’t 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: https://whatswp.com/change-wordpress-login-error-message/

  • By including this code returns me error add_filter('login_errors', create_function('$no_login_error', 'Return "The user name and password is incorrect."'));

  • This error presents me: Parse error: syntax error, Unexpected '}', expecting ';' in /home/hostp064/public_html/49_best/wp-content/themes/Divi/functions.php(8823) : Runtime-created Function on line 1

  • By including this other code it removes the error message, but removes all others as well.

  • I edited my question I could check if you can help me?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.