Profile form is not updated if email is not changed
-
Hi !
I have this code to be able to change my email from the profile form
add_action("um_submit_form_profile","add_field", 1 ); function add_field( $post_form ){ //user mail if( isset( $post_form['user_email'] ) && ! empty( $post_form['user_email'] ) ){ $user = wp_get_current_user(); if( email_exists( $post_form['user_email'] ) && $post_form['user_email'] !== $user->user_email ){ UM()->form()->add_error( 'user_email', __( 'Your email address is already taken', 'ultimate-member' ) ); } } }
And i also have added user_email error via this one (In the profile form ive set up the validate as custom)
add_action( 'um_custom_field_validation_user_email_details', 'um_custom_validate_user_email_details', 999, 3 ); function um_custom_validate_user_email_details( $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', __( 'E-mail Address is required', 'ultimate-member' ) ); } elseif ( ! is_email( $args['user_email'] ) ) { UM()->form()->add_error( 'user_email', __( 'The email you entered is invalid', 'ultimate-member' ) ); } elseif ( email_exists( $args['user_email'] ) ) { UM()->form()->add_error( 'user_email', __( 'The email you entered is already registered', 'ultimate-member' ) ); } } }
So, even if i dont change my email, i have “The email you entered is already registered”.
For my profile form i want email to be if empty, if it’s an invalid email, if the email is already taken by someone else.
I’ve tried to remove the valide custom check but then the only error i get is “The email you entered is incorrect”
Any way to custom the code in the profile form too ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Profile form is not updated if email is not changed’ is closed to new replies.