You are here

function hook_search_api_saved_searches_new_results_alter in Search API Saved Searches 7

Alter or react on new results found for a saved search.

The results will then be used to send a mail to the saved search's creator.

Parameters

array $results: An array of items representing new results for the search. The items that would be sent to the user are passed as loaded items, all others are passed only by ID.

SearchApiSavedSearch $search: The saved search that was executed.

1 invocation of hook_search_api_saved_searches_new_results_alter()
search_api_saved_search_fetch_search_results in ./search_api_saved_searches.module
Fetches the results for a given search object.

File

./search_api_saved_searches.api.php, line 222
Hooks provided by the Search API saved searches module.

Code

function hook_search_api_saved_searches_new_results_alter(array &$results, SearchApiSavedSearch $search) {

  // Remove all results with an ID that is a multiple of 6.
  foreach ($results as $id => $result) {

    // Use is_scalar() to make sure we only remove loaded items that would be
    // sent to the user.
    if (!is_scalar($result) && $id % 6 == 0) {
      unset($results[$id]);
    }
  }
}