Answers.Body: <p>Use <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/" rel="nofollow noreferrer">buildform</a> hook provided by civi in order to add a custom input field on the form. Use this field as a filter eg Event Status.</p>
  
  <p>From the value that is posted from this form(<code>$_POST['event_status']</code>) - filter the result as mentioned by Pradeep using pageRun hook</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-30T08:18:27.040Z
Answers.Text: Hi, Thanks a lot!, I used $form->addElement to create custom input field and was succesful, but having some issues altering $row in hook_pageRun based on event_status value.
Answers.UserDisplayName: harshal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-21T16:45:25.703Z
Answers.Text: I tried add using `$form->addElement` in the `buildForm` hook for `CRM_Member_Form_Search` formName (Search membership), but it doesn't show up.  
  It would be really useful to be able to add a custom filter. Does anyone know how to do this?
Answers.UserDisplayName: masetto
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-30T07:18:57.207Z
Answers.LastActivityDate: 2019-01-30T07:18:57.207Z
Answers.UserDisplayName: jitendra - fuzion
Answers.Body: <p>I would create replica of Manage event using Drupal views with same columns and filters as of Manage event screen. </p>
  
  <p>If you still want to use the same screen then use pageRun hook to manipulate results by generating query and creating results and assigning to template</p>
  
  <pre><code>$page-&gt;assign('rows', $manageEvent);
  </code></pre>
  
  <p>Cheers</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T16:46:52.497Z
Answers.Text: But I want to have all the links Configure, Participants, etc  present in event items and also want to have it on the Manage Events Page, is it not preferable to 1) add a custom select list above 2) alter query ?
Answers.UserDisplayName: harshal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T17:29:09.873Z
Answers.Text: Updated my answer
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T05:08:45.867Z
Answers.Text: Hi @Pradeep, thanks for your invaluable help,but my main question is how I can add custom filter, would request you to provide a link or suitable answer for the same.
Answers.UserDisplayName: harshal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T05:09:30.680Z
Answers.Text: Hi for #2 in the above comment , I have added new question here: https://civicrm.stackexchange.com/questions/28248/how-to-alter-a-query-in-hook-civicrm-pagerun-based-on-a-custom-filter-provided
Answers.UserDisplayName: harshal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T16:20:06.810Z
Answers.LastActivityDate: 2019-01-28T17:29:00.367Z
Answers.LastEditDate: 2019-01-28T17:29:00.367Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p><a href="https://i.sstatic.net/TzttC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TzttC.png" alt="enter image description here"></a></p>
  
  <p>How can I add a custom field (stored as a field in Drupal db) under Manage<br> Events page ,which will be displayed as dropdown.<br>
  Event Status with values <strong>Pending</strong> or <strong>Approved</strong>.<br></p>
  
  <p>How can I alter the filters added as seen in the image?</p>
  
Tags: <civievent><drupal>
Title: How to create a custom filter in CiviCRM manage event page?
ThreadText: # How to create a custom filter in CiviCRM manage event page?
  
  (Asked by: username_0 on 2019-01-28)
  
  [![enter image description here](https://i.sstatic.net/TzttC.png)](https://i.sstatic.net/TzttC.png)
  
  How can I add a custom field (stored as a field in Drupal db) under Manage  
   Events page ,which will be displayed as dropdown.  
  Event Status with values **Pending** or **Approved**.
  
  How can I alter the filters added as seen in the image?
  
  **Tags:** civievent, drupal
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-01-30. Score: 2
  
  Use [buildform](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/) hook provided by civi in order to add a custom input field on the form. Use this field as a filter eg Event Status.
  
  From the value that is posted from this form(`$_POST['event_status']`) - filter the result as mentioned by Pradeep using pageRun hook
  
  > **Comments:**
  > **username_0**: Hi, Thanks a lot!, I used $form->addElement to create custom input field and was succesful, but having some issues altering $row in hook_pageRun based on event_status value.  
  > **username_2**: I tried add using `$form->addElement` in the `buildForm` hook for `CRM_Member_Form_Search` formName (Search membership), but it doesn't show up.   It would be really useful to be able to add a custom filter. Does anyone know how to do this?  
  
  ---
  
  ### Answer by username_3 on 2019-01-28. Score: 2
  
  I would create replica of Manage event using Drupal views with same columns and filters as of Manage event screen. 
  If you still want to use the same screen then use pageRun hook to manipulate results by generating query and creating results and assigning to template
  $page->assign('rows', $manageEvent);
  
  Cheers
  Pradeep
  
  > **Comments:**
  > **username_0**: But I want to have all the links Configure, Participants, etc  present in event items and also want to have it on the Manage Events Page, is it not preferable to 1) add a custom select list above 2) alter query ?  
  > **username_3**: Updated my answer  
  > **username_0**: Hi @Pradeep, thanks for your invaluable help,but my main question is how I can add custom filter, would request you to provide a link or suitable answer for the same.  
  > **username_0**: Hi for #2 in the above comment , I have added new question here: https://civicrm.stackexchange.com/questions/28248/how-to-alter-a-query-in-hook-civicrm-pagerun-based-on-a-custom-filter-provided  
  
  ---
  
  