Skip to content

Instantly share code, notes, and snippets.

@EngKhaledB
Created February 25, 2021 13:06
Show Gist options
  • Save EngKhaledB/4fdabdb1f38b646506eb07f24bc592e8 to your computer and use it in GitHub Desktop.
Save EngKhaledB/4fdabdb1f38b646506eb07f24bc592e8 to your computer and use it in GitHub Desktop.
Allow only Gmail emails on EDD checkout
<?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