function banned_action($errors){
$errors->add( 'invalid_email', $this->options['message'] );
if ( 'yes' === $this->options['redirect'] ) {
wp_safe_redirect( $this->options['redirect_url'] );
} else {
return true;
}
}
function banhammer_drop($user_login, $user_email, $errors) {
$user_email = strtolower($user_email);
$bannedlist_string = $this->bannedlist;
$bannedlist_array = explode("\n", $bannedlist_string);
$bannedlist_size = count($bannedlist_array);
$user_email_arr = explode('@', trim($user_email));
$user_domain = end($user_email_arr);
// Go through bannedlist
for ($i = 0; $i < $bannedlist_size; $i++) {
$bannedlist_current = strtolower(trim($bannedlist_array[$i]));
if ($user_email == $bannedlist_current) { //email exact match
return $this->banned_action($errors);
} else if (strpos($bannedlist_current, '@') !== false && strpos($bannedlist_current, '@') === 0) { //"@domain"
if ('@' .$user_domain == $bannedlist_current ) {
return $this->banned_action($errors);
}
} else if (strpos($bannedlist_current, '@') === false && strpos($bannedlist_current, '.') !== false) {
$banned_have_subdomain = count(explode('.', $bannedlist_current)) > 2;
$user_email_have_subdomain = count(explode('.', $user_domain)) > 2;
if (!$banned_have_subdomain && !$user_email_have_subdomain) {
if (strpos($user_domain, $bannedlist_current) !== false) { //domain.com
return $this->banned_action($errors);
}
} else if ($banned_have_subdomain) {
if (strpos($user_domain, $bannedlist_current) !== false) { //.domain.com
return $this->banned_action($errors);
}
}
}
}
return false;
}
-
This reply was modified 2 years, 3 months ago by bronz.