Last active
January 16, 2026 08:12
-
-
Save xlplugins/8470615fc9c3f6c78ac006de80ebc7ba to your computer and use it in GitHub Desktop.
FunnelKit Checkout Email Validation (domain based)
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
| /** | |
| * Block temporary/disposable email domains during WooCommerce checkout | |
| * Add this to your theme's functions.php file | |
| */ | |
| // Blocked email domains list | |
| function fk_wc_get_blocked_email_domains() { | |
| $domains = array( | |
| 'mailnetter.com', | |
| 'mailnetter.net', | |
| 'mailnetter.org', | |
| '10minutemail.com', | |
| 'guerrillamail.com', | |
| 'mailinator.com', | |
| 'temp-mail.org', | |
| 'tempmail.com', | |
| 'yopmail.com', | |
| 'throwaway.email', | |
| 'trashmail.com', | |
| 'getnada.com', | |
| 'dispostable.com', | |
| 'mohmal.com', | |
| 'spamgourmet.com', | |
| 'maildrop.cc', | |
| 'sharklasers.com', | |
| ); | |
| return apply_filters( 'fk_wc_blocked_email_domains', $domains ); | |
| } | |
| // Validate email domain during checkout | |
| function fk_wc_validate_email_domain( $data, $errors ) { | |
| try { | |
| $email = isset( $data['billing_email'] ) ? sanitize_email( $data['billing_email'] ) : ''; | |
| if ( empty( $email ) ) { | |
| return; | |
| } | |
| $email_parts = explode( '@', $email ); | |
| if ( count( $email_parts ) !== 2 ) { | |
| return; | |
| } | |
| $domain = strtolower( trim( $email_parts[1] ) ); | |
| $blocked_domains = fk_wc_get_blocked_email_domains(); | |
| if ( in_array( $domain, $blocked_domains, true ) ) { | |
| $errors->add( | |
| 'billing_email_validation', | |
| __( 'Sorry, we do not accept temporary or disposable email addresses. Please use a valid email address.', 'woocommerce' ), | |
| array( 'id' => 'billing_email' ) | |
| ); | |
| } | |
| } catch ( Exception $e ) { | |
| // Silently fail to avoid breaking checkout | |
| return; | |
| } | |
| } | |
| add_action( 'woocommerce_after_checkout_validation', 'fk_wc_validate_email_domain', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment