How to alter search query to include custom fields? How can I alter the query for user search (using normal Drupal search) so that instead of searching only email and username, it will also search custom user fields (from fields module)?
For the normal Drupal search you can do so by defining a custom search type in a module.

Use hook_search_info() to define your custom search type &amp; hook_search_execute($keys = NULL, $conditions = NULL) to create or extend your search query.

More available hooks can be found at the Drupal's Search interface or by looking up the search contrib module under yourdrupal\modules\search\search.api.php