Block Disposable Emails at EDD Checkout
Rejects purchases made with throwaway email addresses on the Easy Digital Downloads checkout, so download links and receipts reach a real inbox.
Opens WPIDE on
Code
$wpide_edd_disposable = array( 'mailinator.com', 'guerrillamail.com', '10minutemail.com', 'tempmail.com', 'yopmail.com', 'trashmail.com', 'sharklasers.com', 'getnada.com', 'temp-mail.org' );
add_action( 'edd_checkout_error_checks', function ( $valid_data, $post ) use ( $wpide_edd_disposable ) {
$email = strtolower( (string) ( $post['edd_email'] ?? '' ) );
if ( is_user_logged_in() && '' === $email ) {
$email = strtolower( wp_get_current_user()->user_email );
}
$domain = false !== strpos( $email, '@' ) ? substr( strrchr( $email, '@' ), 1 ) : '';
foreach ( $wpide_edd_disposable as $blocked ) {
if ( $domain && ( $domain === $blocked || substr( $domain, -strlen( '.' . $blocked ) ) === '.' . $blocked ) ) {
edd_set_error( 'wpide_disposable_email', 'Please use a permanent email address so we can send your downloads.' );
return;
}
}
}, 10, 2 );
Notes
Add domains to the list as you spot them; subdomains of listed domains are blocked too.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.