mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Fix email validation logic in Ultimate Member forms
Updated conditions to handle empty and invalid email input more accurately. Ensures required emails are not skipped and includes stricter checks for existing or incorrect emails.
This commit is contained in:
@@ -937,9 +937,9 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! empty( $array['required'] ) && '' === $submitted_data[ $key ] ) {
|
||||
if ( ! empty( $array['required'] ) && empty( $submitted_data[ $key ] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'You must provide your email', 'ultimate-member' ) );
|
||||
} elseif ( ! is_email( $submitted_data[ $key ] ) || email_exists( $submitted_data[ $key ] ) ) {
|
||||
} elseif ( ! empty( $submitted_data[ $key ] ) && ( ! is_email( $submitted_data[ $key ] ) || email_exists( $submitted_data[ $key ] ) ) ) {
|
||||
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
|
||||
} elseif ( 'secondary_user_email' === $key && ! empty( $submitted_data[ $key ] ) && ! empty( $submitted_data['user_email'] ) && $submitted_data[ $key ] === $submitted_data['user_email'] ) {
|
||||
UM()->form()->add_error( $key, __( 'The secondary email cannot be the same as primary', 'ultimate-member' ) );
|
||||
|
||||
Reference in New Issue
Block a user