WooCommerce prohibit account creation with fake emails, ie sharklashers.com
This file contains 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