Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Filters the list of events. Any events belonging to $eventCategory
- * will be removed if the user is not logged in.
- *
- * @param array $events
- * @return array
- */
- function protect_marked_events($events) {
- // If the user is logged in we need take no further action
- if (is_user_logged_in()) return $events;
- // The category name or slug we wish to protect
- $eventCategory = 'heavy-metal';
- // Filter out any events that belong to the above category
- foreach ($events as $id => $event)
- if (has_term($eventCategory, TribeEvents::TAXONOMY, $event->ID))
- unset($events[$id]);
- // Return our modified list of events
- return $events;
- }
- add_filter('tribe_get_events', 'protect_marked_events');
Advertisement
Add Comment
Please, Sign In to add comment