Customize validation messages for login
-
Hello,
When I try to log in, even if the password is correct but my email is wrong, I receive the error below twice.
“Password is incorrect. Please try again.”
1. How can I add a filter in order to check if the email exists and if not display an error message like “the email you entered does not exist.”
I tried following the steps from the article:
https://docs.ultimatemember.com/article/94-apply-custom-validation-to-a-field
I added the code below in the functions.php.my custom action is: email_exists
function um_custom_validate_email_exists( $args ) { $email = isset( $args['user_login'] ) ? $args['user_login'] : ''; // Check if email exists in the database $user = get_user_by( 'email', $email ); if ( ! $user ) { // If email does not exist, add an error message UM()->form()->add_error( 'user_login', 'The email you entered does not exist.' ); } } add_action( 'um_custom_field_validation_email_exists', 'um_custom_validate_email_exists', 999, 1 ); //tried also with um_submit_form_errors_hook_ Also tried the code provided for the registration: add_action( 'um_custom_field_validation_email_exists', 'um_custom_validate_email_exists', 999, 1 ); function um_custom_field_validation_email_exists( $key, $array, $args ) { if ( $key == 'user_email' && isset( $args['user_email'] ) ) { if ( isset( UM()->form()->errors['user_email'] ) ) { unset( UM()->form()->errors['user_email'] ); } if ( empty( $args['user_email'] ) ) { UM()->form()->add_error( 'user_email', __( 'Adresa de E-mail este necesar?', 'ultimate-member' ) ); } elseif ( ! is_email( $args['user_email'] ) ) { UM()->form()->add_error( 'user_email', __( 'E-mailul pe care l-a?i introdus este invalid', 'ultimate-member' ) ); } elseif ( email_exists( $args['user_email'] ) ) { UM()->form()->add_error( 'user_email', __( 'E-mailul pe care l-a?i introdus este deja ?nregistrat', 'ultimate-member' ) ); } } } Still not working.
2. Also, I want to have the validation message displayed once.
“Password is incorrect. Please try again.”
How can I do these?
Thank you, looking forward to your reply.The page I need help with: [log in to see the link]
- The topic ‘Customize validation messages for login’ is closed to new replies.