Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Last active December 5, 2021 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pippinsplugins/2938978 to your computer and use it in GitHub Desktop.
Save pippinsplugins/2938978 to your computer and use it in GitHub Desktop.
Add email confirmation to EDD
<?php
function pw_edd_add_email_confirmation() {
?>
<p>
<label class="edd-label" for="edd-email-confirm">
<?php _e('Confirm Your Email Address', 'easy-digital-downloads'); ?>
<span class="edd-required-indicator">*</span>
</label>
<span class="edd-description" id="edd-email-description"><?php esc_html_e( 'Please confirm your email address.', 'easy-digital-downloads' ); ?></span>
<input class="edd-input required" type="email" name="edd_email_confirm" placeholder="<?php _e('Confirm email address', 'easy-digital-downloads'); ?>" 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( $user, $valid_data, $data ) {
if( empty( $data['edd_email_confirm'] ) || ! is_email( $data['edd_email_confirm'] ) ) {
edd_set_error( 'email_confirmation_required', __( 'Please confirm your email', 'easy-digital-downloads' ) );
}
if( trim( strtolower( $data['edd_email_confirm'] ) ) !== trim( strtolower( $data['edd_email'] ) ) ) {
edd_set_error( 'email_confirmation_required', __( 'Your email addresses do not match', 'easy-digital-downloads' ) );
}
}
add_action('edd_checkout_user_error_checks', 'pw_edd_process_email_confirmation', 10, 3 );
@webstuf
Copy link

webstuf commented Jan 22, 2019

I'm stuck on this one, with this code in place, the email verify in checkout doesn't progress past the validation, even if the emails match. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment