Following an event that we’ve just held, we heard from a few too many people that they hadn’t received the confirmation email. This could obviously have been for a number of reasons, but as I’m not insisting that they register an account, I’d like to be sure that they’ve at least entered a valid email address.
Is there a way of adding a second ‘verify Email’ field to a booking form that won’t allow people to submit the booking until the 2 emails entered match?

Dan Skinner
Hi Dan,
As you’re aware the plug-in doesn’t add a second, ‘confirm your e-mail’ field (perhaps it should), but you can do it with the following:
function my_add_element( $form, $event_id ){
//Get existing email field
$email = $form->get_element( 'email' );
if( !$email ){
return;
}
//Create element to add to the field
$element = EO_Booking_Form_Element_Factory::create( array(
'type' => 'email',
'id' => '_confirm_email', //a unique ID
'required' => 1, //make this field required
'label' => 'Please confirm your e-mail'
) );
//Add the field element, immediately below $email field
$form->add_element( $element, array(
'at' => $email->get( 'position' ) + 1,
'parent' => $email->get_parent()
) );
}
add_action( 'eventorganiser_get_event_booking_form', 'my_add_element', 10, 2 );
Code to validate confirmed e-mail address
function my_validate_element( $form ){
$email= $form->get_element( 'email' );
$email2 = $form->get_element( '_confirm_email' );
if( $email && $email->get_value() !== $email2->get_value() ){
$email2->add_error( 'email-mismatch', "Emails do not match." );
}
}
add_filter( 'eventorganiser_validate_booking_form_submission', 'my_validate_element', 10 );

Stephen Harris
Fab – thanks for the code. Great to know that this kind of stuff can be supported.
Where are these 2 sections augmented to?
NB. I do not currently have templates enabled.
Cheers,
Dan

Dan Skinner
Ideally in a utility plugin, but it will work in theme’s functions.php ( See http://wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/ for details).
It doesn’t require the plugin templates to be enabled.

Stephen Harris
Fantastic – works like a charm 🙂
Many thanks Stephen.

Dan Skinner