SHARE
TWEET

Remove full bookings on events list using shortcode

eventsmanager Apr 5th, 2016 (edited) 280 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top