Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created April 1, 2020 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/03b70b504f9c0cd5a969a9b44629212e to your computer and use it in GitHub Desktop.
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
<?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