Add a custom field in the search form on the event dashboard

Add a custom field in the search form on the event dashboard

In order to add customize search filters to the event dashboard, please enter the following code in the functions.php file:

  1. add_action('event_manager_event_dashboard_event_filter_start', 'my_theme_custom_filter');
  2. function my_theme_custom_filter()
  3. { ?>
  4.     <div class="wpem-events-filter-block">
  5.         <?php $search_location = isset($_GET['search_location']) ? $_GET['search_location'] : ''; ?>        <div class="wpem-form-group"><input name="search_location" id="search_location" type="text" value="<?php echo $search_location; ?>" placeholder="<?php _e('Location','wp-event-manager');?>"></div>
        </div>
  6. <?php }
  7. add_filter( 'event_manager_get_dashboard_events_args', 'my_theme_custom_search', 10 );
  8. function my_theme_custom_search($args)
  9. {
  10.     if( isset($_GET['search_location']) && !empty($_GET['search_location']) )
  11.     {
  12.         $location_meta_keys = array( 'geolocation_formatted_address', '_event_location', 'geolocation_state_long' );
  13.         $location_search    = array( 'relation' => 'OR' );
  14.         foreach ( $location_meta_keys as $meta_key ) {
  15.             $location_search[] = array(
  16.                 'key'     => $meta_key,
  17.                 'value'   => $_GET['search_location'],
  18.                 'compare' => 'like'
  19.             );
  20.         }
  21.         $args['meta_query'][] = $location_search;
  22.     }
  23.     return $args;
  24. }
    • Related Articles

    • Add custom field in Search filter

      It is possible for the users of WP Event Manager to add new filters to the event search form. In this guide we will show you how you can do it. Creating a custom event search filter WP Event Manager’s [Events] shortcode shows a search filter on the ...
    • Creating a custom event search form

      WP Event Manager’s [Events] shortcode is coded to pick up search_location and search_keywords variables from the query string. Because of this, it’s easy to create a search form elsewhere on your site which posts to your events page. How to Create a ...
    • Editing Event Submission Form Fields

      There are mainly 2 ways to customize the form fields in WP Event Manager : Using the Field editor option from the admin panel. Using the WordPress hooks (filters) which are explained below. Using the field editor option from the admin panel To add, ...
    • Remove existing field from event submission form

      Removing fields from event the event submission form In this guide, you will learn about how you can remove existing fields from the event submission form and how you can remove some social fields from the organizer section. Remove existing field ...
    • Installation of WP Event Manager

      Automatic Installation of FREE WP Event Manager Installing WP Event Manager is just a matter of a few clicks. You can add WP Event Manager to your website by using the dashboard offered to you at the backend of the CMS. To install the plugin ...