最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - How to translate wordpress error message

programmeradmin1浏览0评论

I have a problem and I am not finding the variable to solve, 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!

I even managed to change the error message, but it is replicating to all other pages, I would like it to appear only on the login page

I tried to make it appear only on the login page this way

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!";
    }
}

I have a problem and I am not finding the variable to solve, 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!

I even managed to change the error message, but it is replicating to all other pages, I would like it to appear only on the login page

I tried to make it appear only on the login page this way

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!";
    }
}
Share Improve this question asked Dec 6, 2017 at 10:51 FernandoFernando 112 bronze badges 7
  • Which language have you selected in the backend, page "Settings" ? – mmm Commented Dec 6, 2017 at 10:57
  • Was Português BR – Fernando Commented Dec 6, 2017 at 10:59
  • have you the last wordpress version ? I have try with version 4.9.1 and the language name is "Português do Brasil" and not "Português BR". And after I try with a wrong username, it writes "ERRO: Nome de usuário inválido. Perdeu a senha?" – mmm Commented Dec 6, 2017 at 11:16
  • É esse erro que me retorna – Fernando Commented Dec 6, 2017 at 13:45
  • snag.gy/pI9xeZ.jpg – Fernando Commented Dec 6, 2017 at 13:46
 |  Show 2 more comments

1 Answer 1

Reset to default 1

I was able to solve my problem, follow the code in case someone needs the 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 from where I located the answer: Change login error messages

发布评论

评论列表(0)

  1. 暂无评论