Created
February 2, 2016 13:45
-
-
Save alessandrotesoro/be18855eddde18a43f81 to your computer and use it in GitHub Desktop.
WPUM add email confirmation at registration
This file contains hidden or 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_new_email_field( $fields ) { | |
$fields[ 'confirm_email' ] = array( | |
'label' => 'Confirm Email', | |
'type' => 'email', | |
'meta' => 'email_confirmation', | |
'required' => true, | |
'description' => 'Add something here if needed', | |
); | |
return $fields; | |
} | |
add_filter( 'wpum_get_registration_fields', 'wpum_add_new_email_field' ); | |
function wpum_verify_email_confirmation( $passed, $fields, $values ) { | |
$first_email = $values['register'][ 'user_email' ]; | |
$confirm_email = $values['register'][ 'confirm_email' ]; | |
if( $first_email !== $confirm_email ) { | |
return new WP_Error( 'email-validation-error', 'Email mismatch' ); | |
} | |
return $passed; | |
} | |
add_filter( 'wpum/form/validate=register', 'wpum_verify_email_confirmation', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there anyway to control the displaying of the fields? In the theme I am using it shows email, password then confirmation email. I would like the two email boxes under each other.
And obviously, this git entry worked like a champ so thanks!
Geoff.