function cleantalk_find_spam_users in Anti Spam by CleanTalk 7.4
Same name and namespace in other branches
- 7.5 src/Form/CleantalkCheckUsersForm.php \cleantalk_find_spam_users()
1 call to cleantalk_find_spam_users()
- find_spam_users_btn in src/
Form/ CleantalkCheckUsersForm.php
File
- src/
Form/ CleantalkCheckUsersForm.php, line 132 - CleanTalk module admin functions.
Code
function cleantalk_find_spam_users($accounts) {
// Get all accounts
$spam_users = array();
if ($accounts && count($accounts) > 0) {
$data = array();
foreach ($accounts as $account) {
// Skip adding the role to the user if they already have it.
if ($account !== FALSE && isset($account->mail)) {
array_push($data, $account->mail);
}
}
$data = implode(',', $data);
$result = CleantalkHelper::api_method__spam_check_cms(trim(variable_get('cleantalk_authkey', '')), $data);
if (isset($result['error_message'])) {
drupal_set_message($result['error_message'], 'error');
}
else {
foreach ($result as $key => $value) {
if ($value['appears'] == '1') {
foreach ($accounts as $account) {
if ($account->mail == $key) {
$spam_users[] = $account;
}
}
}
}
}
}
return $spam_users;
}