Created
June 1, 2018 12:18
-
-
Save alessandrotesoro/22de8830219dec313878ce243db0f62a to your computer and use it in GitHub Desktop.
WPUM 2.0.0 Double email confirmation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpum_add_custom_email_field( $fields ) { | |
$fields['verify_email'] = array( | |
'label' => 'Verify email', | |
'type' => 'email', | |
'required' => true, | |
'description' => 'Verify your email address.', | |
'priority' => 9998, | |
); | |
return $fields; | |
} | |
add_filter( 'wpum_get_registration_fields', 'wpum_add_custom_email_field' ); | |
function wpum_verify_email_matches( $pass, $fields, $values, $form ) { | |
if ( $form == 'registration' && isset( $fields['register']['user_email'] ) ) { | |
$email = $values['register']['user_email']; | |
$second_email = isset( $values['register']['verify_email'] ) ? $values['register']['verify_email'] : false; | |
if ( $email !== $second_email ) { | |
return new WP_Error( 'email-error', 'Email does not match.' ); | |
} | |
} | |
return $pass; | |
} | |
add_filter( 'submit_wpum_form_validate_fields', 'wpum_verify_email_matches', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment