eventsmanager

Remove full bookings on events list using shortcode

Apr 5th, 2016
396
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * This snippet will remove events with full bookings
  3. *
  4. * Usage: [events_list scope="future" hide_closed_bookings=1 pagination=1]
  5. */
  6.  
  7. add_filter('em_events_get_default_search','my_em_search_remove_events_closed_bookings',1,2);
  8. function my_em_search_remove_events_closed_bookings($searches, $array){
  9. if( !empty($array['hide_closed_bookings']) ){
  10. $searches['hide_closed_bookings'] = $array['hide_closed_bookings'];
  11. }
  12. return $searches;
  13. }
  14.  
  15. add_filter('em_events_get','my_em_remove_events_closed_bookings',1,2);
  16. function my_em_remove_events_closed_bookings($events, $args){
  17. if( !empty($args['hide_closed_bookings']) && $args['hide_closed_bookings'] == 1 ){
  18. foreach($events as $event_key => $EM_Event){
  19. if ( $EM_Event->event_rsvp && !$EM_Event->get_bookings()->is_open() ){
  20. unset($events[$event_key]);
  21. }
  22. }
  23. }
  24. return $events;
  25. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×