Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce prohibit account creation with fake emails, ie sharklashers.com
<?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
You can’t perform that action at this time.