Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WPUM 2.0.0 Double email confirmation
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
You can’t perform that action at this time.