Add an Email Confirmation Field
Sometimes you may find that you want to add a second email field for requiring that the buyer confirms their email address by entering it twice. This is really quite simple to do, just paste the following snippet into your functions.php or any custom plugin:
function pw_edd_add_email_confirmation() {
?>
<p>
<label class="edd-label" for="edd-email-confirm"><?php _e('Confirm Your Email Address', 'edd'); ?></label>
<input class="edd-input required" type="email" name="edd_email_confirm" placeholder="<?php _e('Confirm email address', 'edd'); ?>" id="edd-emai-confirm" value=""/>
</p>
<?php
}
add_action('edd_purchase_form_after_email', 'pw_edd_add_email_confirmation');
function pw_edd_process_email_confirmation($valid_data, $data) {
if( $valid_data['need_new_user'] == false ) {
return;
}
if( !isset($data['edd_email_confirm'] ) || !is_email( $data['edd_email_confirm'] ) ) {
edd_set_error( 'email_confirmation_required', __( 'Please confirm your email', 'edd' ) );
}
if( trim( $data['edd_email_confirm'] ) != trim( $data['edd_email'] ) ) {
edd_set_error( 'email_confirmation_required', __( 'Your email addresses do not match', 'edd' ) );
}
}
add_action('edd_checkout_error_checks', 'pw_edd_process_email_confirmation', 10, 2);