Last active
September 12, 2018 14:07
-
-
Save kloon/37fcf6c8b6a1e8afaba8a594bfe44331 to your computer and use it in GitHub Desktop.
WooCommerce prohibit account creation with fake emails, ie sharklashers.com
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 | |
/** | |
* Do not allow account creation with temp email addresses | |
* @param Object $validation_errors | |
* @param string $username | |
* @param string $email | |
* @return WP_Error | |
*/ | |
function do_not_allow_temp_email_addresses( $validation_errors, $username, $email ) { | |
$prohibitied_domains = array( | |
'sharklasers.com', | |
'grr.la', | |
'guerrillamail.biz', | |
'guerrillamail.com', | |
'guerrillamail.de', | |
'guerrillamail.net', | |
'guerrillamail.org', | |
'guerrillamailblock.com', | |
'spam4.me', | |
); | |
$email_domain = explode( '@', $email )[1]; | |
if ( in_array( $email_domain, $prohibitied_domains ) ) { | |
return new WP_Error( 'registration-error-bad-email', __( 'Please use a valid email address.' ) ); | |
} | |
return $validation_errors; | |
} // End do_not_allow_temp_email_addresses() | |
add_filter( 'woocommerce_registration_errors', 'do_not_allow_temp_email_addresses', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment