Hi @ronenlan
If you would like to to change how blank username/password is treated:
Please use the following code in the functions.php of the active theme of your site.
add_filter( 'authenticate', 'custom_authenticate_username_password', 30, 3);
function custom_authenticate_username_password( $user, $username, $password )
{
if ( is_a($user, 'WP_User') ) { return $user; }
if ( empty($username) || empty($password) )
{
$error = new WP_Error();
$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Empty EMAIL!!'));
return $user;
}
}
And then your original redirect on wp_login_failed will work with blank username/password as well.
Please let me know if you have any questions.
Regards!
Hey Saroj!
Thanks a lot for your answer.
Unfortunately, it’s still doesn’t work but there is also a problem with non-blank fields.
For example, if I try to login with an email address that ins’t associated to any account, the action is not firing as well.
This is the code I am using to catch ‘wp_login_failed’:
//after unsuccessful login
add_action('wp_login_failed', 'user_unsuccessful_login', 10, 2);
function user_unsuccessful_login( $user_login,$error) {
e()->track("User unsuccessfully tried to log in", array("Email" => $user_login, "Error" => $error->get_error_codes()));
}
This code seems to execute only when the email address is correct and the password is not.
When the email is blank or not associated to any user account, the function isn’t called.
This happens also after adding the code you shared with me.
Thanks a lot in advance!
Hey @wpeverestsupportrep
Can you please help me with that issue?
Thanks!