Created
February 25, 2021 13:06
-
-
Save EngKhaledB/4fdabdb1f38b646506eb07f24bc592e8 to your computer and use it in GitHub Desktop.
Allow only Gmail emails on EDD checkout
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 | |
// Add this code to functions.php | |
function checkout_allow_only_gmail_emails( $valid_data, $posted ) { | |
if ( ! empty( $posted['edd_email'] ) ) { | |
list( $user_id, $domain ) = explode( '@', $posted['edd_email'] ); | |
if ( strtolower( $domain ) != 'gmail.com' ) { | |
edd_set_error( 'email_not_allowed', 'Only Google emails are allowed!' ); | |
} | |
} | |
} | |
add_action( 'edd_checkout_error_checks', 'checkout_allow_only_gmail_emails', 11, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment