functions.php: add filter for spam email by domains

This commit is contained in:
Silvan Calarco 2023-08-17 10:00:05 +02:00
parent 0e26e955f0
commit ba1254a768

View File

@ -431,3 +431,20 @@ function restrict_rest_api_to_localhost() {
}
}
add_action( 'rest_api_init', 'restrict_rest_api_to_localhost', 0 );
/* Security: filter email domains frequently used for spam registrations */
function user_registration_filter($user_id, $email) {
if ($user_id == false) {
$e1 = explode("@", $email);
if (in_array($e1[1], array(
'xtra.ltd','tmobile.agency','btee.online','verizonconnect.online',
'eduonline.digital','vofadonepro.online'))) {
error_log( "user_registration_filter: email=" . $email . " blacklisted domain=" . $e1[1] );
$user_id = 100;
} else {
error_log( "user_registration_filter: email=" . $email . " whitelisted domain=" . $e1[1] );
}
}
return $user_id;
}
add_filter('email_exists', 'user_registration_filter', 10, 2);