Last active
December 5, 2021 15:59
-
-
Save pippinsplugins/2938978 to your computer and use it in GitHub Desktop.
Add email confirmation to EDD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?