From: Steve Sutton Date: Fri, 27 Apr 2018 15:20:24 +0000 (-0400) Subject: Update for event detail pages for active events only. X-Git-Tag: v1.6.82^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=381200c2ac660c0b3bfa6943ee94773e5b0a49ca;p=WP-Plugins%2Fglm-member-db-events.git Update for event detail pages for active events only. If anything but active give 404 page. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 6e823fc..bc797a2 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -81,11 +81,30 @@ if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, '/'.$this->config['settings']['canoni // Get the event name for use in the page title global $wpdb; $eventData = $wpdb->get_row( - "SELECT name,intro + "SELECT name,intro,status FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events - WHERE name_slug = '".$GLOBALS['glmDetailSlug']."'", + WHERE name_slug = '".$GLOBALS['glmDetailSlug']."' + AND status = " . $this->config['status_numb']['Active'] . "", ARRAY_A ); + if ( ! $eventData ) { + // If the eventData is not found then create 404 + function glm_throw_404(){ + global $wp_query; + $wp_query->set_404(); + status_header( 404 ); + nocache_headers(); + add_filter('wp_title', function($title) { + return 'Error 404 - Not Found!'; + }, 99, 1); + $template404 = get_404_template(); + if ( $template404 ) { + require $template404; + } + exit; + } + add_action('wp', 'glm_throw_404'); + } $GLOBALS['glmEventName'] = $eventData['name']; $GLOBALS['glmEventIntro'] = $eventData['intro']; @@ -203,7 +222,7 @@ if (isset($this->config['addOns']['glm-member-db'])) { 10, 2 ); - + // Add content to member detail page - Get it from the existing event listing shortcode // Unlike the filters above this one is not listed by default on the member detail page // but can be applied to custom member db view files if they remove any "descriptionAfter"