eventsmanager

Workaround fix: {waitlist_full} ... {/waitlist_full}

Mar 3rd, 2025
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. function my_em_event_output_show_condition($show, $condition, $full_match, $EM_Event){
  4. global $wpdb;
  5. switch ($condition) {
  6.  
  7. case 'waitlist_full' : // waitlist is enabled and full
  8. $reserved = $wpdb->get_var('SELECT SUM(booking_spaces) FROM '.EM_BOOKINGS_TABLE.' WHERE event_id='. absint($EM_Event->event_id) .' AND booking_status=6 GROUP BY event_id');
  9. $is_enabled = get_option('dbem_waitlists');
  10. $is_fully_booked = $reserved <= 0;
  11. $is_waitlist_available = $EM_Event->get_bookings()->get_available_spaces();
  12. $show = $is_enabled && $is_fully_booked && $is_waitlist_available;
  13. if( $condition === 'waitlist_closed' ) $show = !$show; // opposite of closed
  14. if( $condition === 'waitlist_full' ) $show = $is_enabled && $is_fully_booked && !$is_waitlist_available; // only waitlist should be unavailable here
  15. break;
  16.  
  17. }
  18. return $show;
  19. }
  20. add_filter('em_event_output_show_condition', 'my_em_event_output_show_condition', 100, 4);
Advertisement
Add Comment
Please, Sign In to add comment