Created
April 1, 2020 21:40
-
-
Save joshfeck/03b70b504f9c0cd5a969a9b44629212e to your computer and use it in GitHub Desktop.
Exclude events with venue identifier "online" from being displayed in the EE4 calendar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_filter( | |
'FHEE__EED_Espresso_Calendar__get_calendar_events__query_params', | |
'my_exclude_online_venue_calendar_filter', | |
10, | |
7 | |
); | |
function my_exclude_online_venue_calendar_filter( | |
$query_params, | |
$category_id_or_slug, | |
$venue_id_or_slug, | |
$public_event_stati, | |
$start_date, | |
$end_date, | |
$show_expired | |
) { | |
// get all venues | |
$venues = array(); | |
$venues = EEM_Venue::instance()->get_all(); | |
// create loop to insert IDs to array | |
foreach( $venues as $venue ) { | |
if (!$venue instanceof EE_Venue) { | |
continue; | |
} | |
// exclude venue 'online' only! | |
if ($venue->get('VNU_identifier') != 'online') { | |
$venue_ids[] = $venue->id(); | |
} | |
} | |
$query_params[0]['OR*venue'] = array( | |
'Event.Venue.VNU_ID' => array( 'in', $venue_ids ), | |
); | |
return $query_params; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment