Page 1 of 1

Create a confirm email field to match in the registration

PostPosted: Wed Sep 07, 2016 8:39 pm
by admin
Sometimes is better to have another email field in a registration form to confirm that the new user email address is correct (without errors, or typos) therefore we perform an email verification within the form itself.

Go to:

UM > Forms > Default Registration and click on edit.

edit-registration-form.gif
edit-registration-form.gif (19.07 KiB) Viewed 1844 times


Add a field and select a 'Text Box': You can fill in or change everything else in the text box except these 7 fields which need to be entered exactly this way:

  1. Title: Email Confirm
  2. Label: Email Confirm
  3. Meta Key: email_confirm (all lower case)
  4. Privacy: Everyone
  5. Visibility: View Everywhere
  6. Is this field required? Yes
  7. Can user edit this field? Yes

add-text-box.gif
add-text-box.gif (13.6 KiB) Viewed 1844 times


You are done creating your email confirmation form field in UM.

new-registration-form.gif
new-registration-form.gif (14.94 KiB) Viewed 1844 times

Next, go to Appearance > Editor > Theme Functions (steps 1 & 2).

edit-theme-functions.gif
edit-theme-functions.gif (33.5 KiB) Viewed 1844 times

Copy and paste the following code at the bottom of the theme's functions.php (step 3):

Code: Select all
// check both email fields to match in the registration form
add_action('um_submit_form_errors_hook', 'avnw_email_confirmation', 10 );
function avnw_email_confirmation( $args ){
global $ultimatemember;
if( $args['user_email'] != $args['email_confirm'] ) {
 $ultimatemember->form->add_error( 'user_email', 'your email does not match');
}
}



You should now have a confirmation email field set up in your registration form, so if someone types an address different from the email address field, the registration form will not be submitted and an error message: "your email does not match" will appear.

email-confirmation-field.gif
email-confirmation-field.gif (7.66 KiB) Viewed 1844 times

Re: Create a confirm email field to match in the registratio

PostPosted: Sat Oct 03, 2020 3:44 pm
by PeteB
Hi - I'd love to be able to use this code to enable an email confirmation field in a UM registration form - but if I add the code I just get a blank page when I submit the registration form. Is there an update for it possibly - I realise it's 4yrs old now . . .

Many thanks
Pete

Re: Create a confirm email field to match in the registratio

PostPosted: Sat Oct 31, 2020 10:57 am
by admin
PeteB wrote:Hi - I'd love to be able to use this code to enable an email confirmation field in a UM registration form - but if I add the code I just get a blank page when I submit the registration form. Is there an update for it possibly - I realise it's 4yrs old now . . .

Many thanks
Pete


Hard to say why but yes, this worked on UM 4 years ago. Regardless, make sure you check your functions.php in your WordPress theme's folder and that is actually coded the way it was instructed above. Otherwise, you may have placed the code the wrong way or in the wrong place.

Hope this helps,