"Confirm Email" Field at EDD Checkout
Asks guest buyers to type their email address twice on the Easy Digital Downloads checkout, preventing typos that would stop their download links arriving.
Opens WPIDE on
Code
add_action( 'edd_purchase_form_after_email', function () {
if ( is_user_logged_in() ) {
return;
}
?>
<p id="edd-email-confirm-wrap">
<label class="edd-label" for="edd-email-confirm"><?php echo esc_html( 'Confirm email address' ); ?> <span class="edd-required-indicator">*</span></label>
<input class="edd-input required" type="email" name="edd_email_confirm" id="edd-email-confirm" autocomplete="email" required>
</p>
<?php
} );
add_action( 'edd_checkout_error_checks', function ( $valid_data, $post ) {
if ( is_user_logged_in() || ! isset( $post['edd_email'] ) ) {
return;
}
if ( strtolower( trim( (string) $post['edd_email'] ) ) !== strtolower( trim( (string) ( $post['edd_email_confirm'] ?? '' ) ) ) ) {
edd_set_error( 'wpide_email_mismatch', 'The email addresses do not match. Please check them.' );
}
}, 10, 2 );
Notes
Logged-in customers do not see the extra field.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.