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
1 Answer
Reset to default 1I 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