I want to hook the Drupal advance search form for add more filter criteria,

I want to add the below criteria
1) Search By Post Date
2) Search Between Post Date
3) Search by last day, last 7 days

I applied the hook Mymodule_search_form_alter(&$form, $form_state) {} to add the fields,

Please You suggest me Guys that how can i alter the search query, i am looking for this by last 2 days, but nothing found

This is the link that i got only


But that not works,

Any suggestions Please...!!

1 Answer 1


To alter the query itself, try hook_search_api_query_alter (for search api) or hook_search_execute for the core search

  • Can You Provide Further Instructions, how to implement as i found nothing in my search module
    – sanjay
    Commented Jun 26, 2014 at 5:10
  • I updated my answer (missed half the sentence, sorry) - I have never modified the search query, so this is as much as I can provide - a search should yield more information on how to implement these
    – Geoff
    Commented Jun 26, 2014 at 13:17
  • i already execute that but that create the separate path for my custom module that i created for hook, i want to merge my fields with the advance form fields & make it searchable..i wasted my weeks or so, but still cant find nothing... #by d way Thanks
    – sanjay
    Commented Jun 27, 2014 at 13:14
  • you can add form elements via hook_form_alter, but you would then need to run your own query update to include that information, presumably through hook_search_execute and reference the new form elements you create
    – Geoff
    Commented Jun 27, 2014 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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