Block Disposable Email Addresses on Registration
Rejects registrations from throwaway email services, which are a common source of fake and spam accounts.
Opens WPIDE on
Code
// Domains to reject. Add more as you see them in your users list.
$wpide_disposable_domains = array(
'mailinator.com', 'guerrillamail.com', 'guerrillamail.net', '10minutemail.com', 'tempmail.com', 'temp-mail.org',
'yopmail.com', 'trashmail.com', 'getnada.com', 'sharklasers.com', 'dispostable.com', 'maildrop.cc',
'throwawaymail.com', 'fakeinbox.com', 'mintemail.com', 'spamgourmet.com', 'emailondeck.com', 'moakt.com',
);
add_filter( 'registration_errors', function ( $errors, $login, $email ) use ( $wpide_disposable_domains ) {
$domain = strtolower( (string) substr( strrchr( (string) $email, '@' ), 1 ) );
foreach ( $wpide_disposable_domains as $blocked ) {
if ( $domain === $blocked || ( strlen( $domain ) > strlen( $blocked ) && substr( $domain, -strlen( $blocked ) - 1 ) === '.' . $blocked ) ) {
$errors->add( 'wpide_disposable_email', '<strong>Error:</strong> Please use a permanent email address.' );
break;
}
}
return $errors;
}, 10, 3 );
Notes
Subdomains of listed domains are blocked as well.
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.