public function SearchApiAlterUserStatus::alterItems in Search API 7
Alter items before indexing.
Items which are removed from the array won't be indexed, but will be marked as clean for future indexing. This could for instance be used to implement some sort of access filter for security purposes (e.g., don't index unpublished nodes or comments).
Parameters
array $items: An array of items to be altered, keyed by item IDs.
Overrides SearchApiAlterCallbackInterface::alterItems
File
- includes/
callback_user_status.inc, line 26 - Contains the SearchApiAlterUserStatus class.
Class
- SearchApiAlterUserStatus
- Filters out blocked user accounts.
Code
public function alterItems(array &$items) {
$multi_types = $this
->isMultiEntityIndex($this->index);
foreach ($items as $id => $item) {
$account = $item;
if ($multi_types) {
if ($item->item_type !== 'user') {
continue;
}
$account = $item->user;
}
if (empty($account->status)) {
unset($items[$id]);
}
}
}