From ba1254a768489111dbb141b9280a75ae5552c090 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Thu, 17 Aug 2023 10:00:05 +0200 Subject: [PATCH] functions.php: add filter for spam email by domains --- functions.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/functions.php b/functions.php index 6340e53..d162d1f 100644 --- a/functions.php +++ b/functions.php @@ -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);