I'm looking for a way to exclude certain users (by ID or name) from appearing in the user search results in Drupal 7.

Any thoughts?


If you're using drupal search out of the box to search users, that should still call implementations of hook_search_page

Build a small custom module that implements hook_search_page, parse thru $results and remove anything you don't want appearing in search results.

function custom_module_search_page($results) {
  foreach($results as $result_index => $result) { 
    //do something, maybe detect for a user id
    //and run unset($results[$result_index]); if the criteria is met

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.