This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

Users can mess up the registration process by making a typographical error in their email address when completing a registration form. A common solution is to require them to add a second copy of their email address as a guard against such mistakes. Of course, they could just copy and paste, but hopefully those that are clever enough to copy and paste are also clever enough to not make trivial mistakes in their email addresses.

This how-to breaks into two parts, changing the form and changing the validation of the form.

To change the form

Copy the file /concrete/single_pages/register.php to /single_pages/register.php. (You may have already done this to add a custom register page for your theme as described at http://www.concrete5.org/community/forums/chat/custom-register-page-with-single-pages/ )

Edit the new file and find:

<div title="<?php echo t('This must be a valid email address because you will need to click a link in an email we send you to validate your registration.')?>">
<?php echo $form->label('uEmail', t('Email Address') )?>
<?php echo $form->text('uEmail')?>
</div>
<br/>

Copy, insert copy and edit it to:

<div title="<?php echo t('This must be a valid email address because you will need to click a link in an email we send you to validate your registration.')?>">
<?php echo $form->label('uEmail', t('Email Address') )?>
<?php echo $form->text('uEmail')?>
</div>
<br/>
<div title="<?php echo t('This must be identical to the email address you entered above.')?>">
<?php echo $form->label('uEmailConfirm', t('Confirm Email Address') )?>
<?php echo $form->text('uEmailConfirm')?>
</div>
<br/>

To change the form validation

Copy the file /concrete/controllers/register.php to /controllers/register.php.

Edit the new file and find:

if (!$vals->email($_POST['uEmail'])) {
    $e->add(t('Invalid email address provided.'));
} else if (!$valc->isUniqueEmail($_POST['uEmail'])) {
    $e->add(t("The email address %s is already in use. Please choose another.", $_POST['uEmail']));
}

Edit the start of this to:

if ($_POST['uEmail'] != $_POST['uEmailConfirm']) {
    $e->add(t('The two email addresses provided do not match.'));
} else if (!$vals->email($_POST['uEmail'])) {
    $e->add(t('Invalid email address provided.'));
} else if (!$valc->isUniqueEmail($_POST['uEmail'])) {
    $e->add(t("The email address %s is already in use. Please choose another.", $_POST['uEmail']));
}

That should be it, job done. Any registering user who does not input a second copy of their email address that matches the first will now get an error message and instructions to correct it.

Read more How-tos by JohntheFish

Loading Conversation