From: Steve Sutton Date: Tue, 11 Dec 2018 21:44:36 +0000 (-0500) Subject: Updating front hooks with new filters X-Git-Tag: v1.7.14^2~9 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=25d50eae8afdfc6c136ec897957b3d9b5ba87ba3;p=WP-Plugins%2Fglm-member-db-events.git Updating front hooks with new filters Adding filters for the uptravel drop downs. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index bc797a2..950b339 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -245,3 +245,71 @@ add_filter( 'glm-member-db-events-get-event-data', function( $event_id ){ return $events; } ); +// Grab months for drop down +add_filter( 'glm-member-db-events-get-months-search', function() { + $months = array(); + $from = date('Y-m-d', strtotime('now')); + $events = $this->wpdb->get_results( + $this->wpdb->prepare( + "SELECT distinct DATE_FORMAT( start_time, '%b %Y' ) as monthsel, DATE_FORMAT( start_time, '%m %Y' ) as monthval + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times + WHERE active + AND DATE(start_time) >= '%s' + ORDER by start_time + ", + $from + ), + ARRAY_A + ); + return $events; +}, 10, 2 ); + +// Grab regions for drop down +add_filter( 'glm-member-db-events-get-region-search', function() { + $regions = array(); + $from = date('Y-m-d', strtotime('now')); + // Get all regions from the location table. + // This will not get those events with members that are in a region. + $regions = $this->wpdb->get_results( + "SELECT id,name + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "regions + WHERE id IN ( + SELECT region + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations + WHERE event IN ( + SELECT event + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times + WHERE active + AND DATE(start_time) >= '%s' + ) + ) + ORDER BY name", + ARRAY_A + ); + return $regions; +}, 10,2 ); + +// Grab Categories for drop down +add_filter( 'glm-member-db-events-get-category-search', function() { + $categories = array(); + $from = date('Y-m-d', strtotime('now')); + // Get all categories from the location table. + // This will not get those events with members that are in a region. + $categories = $this->wpdb->get_results( + "SELECT id,name + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories + WHERE id IN ( + SELECT category + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories + WHERE event IN ( + SELECT event + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times + WHERE active + AND DATE(start_time) >= '%s' + ) + ) + ORDER BY name", + ARRAY_A + ); + return $categories; +}, 10,2 );