eventsmanager

Prevent guest users from booking before waitlists

Mar 21st, 2026 (edited)
3,642
-1
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 1
  1. <?php
  2.  
  3. /*
  4. * Prevent guest users from booking before waitlists
  5. */
  6.  
  7. add_filter('em_bookings_is_open','my_booking_open', 100, 2);
  8.  
  9. function my_booking_open( $return, $EM_Bookings ){
  10. global $wpdb;
  11.  
  12. if( get_option('dbem_waitlists_events') && !is_user_logged_in() ) {
  13.  
  14. $EM_Event = $EM_Bookings->get_event();
  15.  
  16. $waitlist_events = get_option('dbem_waitlists_events_default');
  17.  
  18. if ( $waitlist_events ){
  19.  
  20. if (!empty($EM_Event->event_attributes['waitlist'])) {
  21.  
  22. /* start */
  23. if ( isset($_REQUEST['uuid']) ){
  24.  
  25. $sql = 'SELECT booking_status FROM '.EM_BOOKINGS_TABLE. ' WHERE booking_status = 7 AND booking_uuid = %s ';
  26. $status = $wpdb->get_var( $wpdb->prepare($sql, $_REQUEST['uuid']) );
  27.  
  28. if ( $status == 7 ){
  29. $return = true;
  30. return $return;
  31. }
  32.  
  33. }
  34. /* end */
  35.  
  36. $statuses = array(6);
  37.  
  38. $sql = 'SELECT SUM(booking_spaces) FROM '.EM_BOOKINGS_TABLE. ' WHERE booking_status IN ('. implode(',', $statuses) .') AND event_id=%d';
  39.  
  40. $pending_spaces = $wpdb->get_var( $wpdb->prepare($sql, $EM_Bookings->event_id) );
  41.  
  42. if ( $pending_spaces > 0 ){
  43. $return = false;
  44. add_filter('em_event_output_placeholder', 'my_em_bookinform', 100, 3);
  45. }
  46.  
  47.  
  48. }
  49.  
  50. }
  51.  
  52. }
  53.  
  54.  
  55. if( get_option('dbem_waitlists_events') && is_user_logged_in() ) {
  56.  
  57. /* start */
  58. if ( isset($_REQUEST['uuid']) ){
  59.  
  60. $sql = 'SELECT booking_status FROM '.EM_BOOKINGS_TABLE. ' WHERE booking_status = 7 AND booking_uuid = %s ';
  61. $status = $wpdb->get_var( $wpdb->prepare($sql, $_REQUEST['uuid']) );
  62.  
  63. if ( $status == 7 ){
  64. $return = true;
  65. return $return;
  66. }
  67.  
  68. }
  69. /* end */
  70.  
  71. $current_user = wp_get_current_user(); //$current_user->ID
  72.  
  73. $statuses = array(6); //6 - waiting // 7 - approved
  74.  
  75. $sql = 'SELECT SUM(booking_spaces) FROM '.EM_BOOKINGS_TABLE. ' WHERE booking_status IN ('. implode(',', $statuses) .') AND event_id=%d AND person_id=%d';
  76.  
  77. $pending_spaces = $wpdb->get_var( $wpdb->prepare($sql, $EM_Bookings->event_id, $current_user->ID ) );
  78.  
  79. if ( $pending_spaces > 0 && !isset($_REQUEST['uuid']) ){
  80. $return = false;
  81. add_filter('em_event_output_placeholder', 'my_em_bookinform_already_waiting', 100, 3);
  82. } else {
  83. $return = false;
  84. add_filter('em_event_output_placeholder', 'my_em_bookinform', 100, 3);
  85. }
  86.  
  87. }
  88.  
  89. return $return;
  90. }
  91.  
  92. function my_em_bookinform_already_waiting($replace, $EM_Event, $result) {
  93. if ( $result == '#_BOOKINGFORM' ) {
  94. include( emp_locate_template('waitlists/already-waiting.php') );
  95. return ob_get_clean();
  96. }
  97. return $replace;
  98. }
  99.  
  100. function my_em_bookinform($replace, $EM_Event, $result) {
  101. if ( $result == '#_BOOKINGFORM' ) {
  102. include( emp_locate_template('waitlists/form.php') );
  103.  
  104. echo "<script>";
  105. include( emp_locate_template('waitlists/waitlists.js') );
  106. echo "</script>";
  107.  
  108. return ob_get_clean();
  109. }
  110. return $replace;
  111. }
Advertisement
Comments
  • User was banned
  • User was banned
  • Vintawyn
    53 days
    # CSS 0.06 KB | 0 0
    1. You literally stole this exploit from https://t.me/theprotocolone
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment