Skip to content

Instantly share code, notes, and snippets.

@alessandrotesoro
Created June 1, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessandrotesoro/22de8830219dec313878ce243db0f62a to your computer and use it in GitHub Desktop.
Save alessandrotesoro/22de8830219dec313878ce243db0f62a to your computer and use it in GitHub Desktop.
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