• Resolved ToobHed

    (@toobhed)


    I don’t want users who have been rejected for an event to continue seeing the booking button. Is there a way to hide this? There is a line of code in bookingbutton.php that checks booking_status
    if( is_object($EM_Booking) && $EM_Booking->booking_status != 3...
    When I try to echo the value for booking_status I don’t get anything unless it is value 1 (2 is what gets recorded when a registration is rejected) I have tried calling :
    $EM_Bookings = $EM_Event->get_bookings()->get_rejected_bookings();
    I get an array but I can’t seem to figure out how to find a way to get the booking status for the logged in user from this array. Any help or insight?

    https://ww.wp.xz.cn/plugins/events-manager/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    you might need additional loop to make this work since an event can contain one or more bookings and you can might additional coding to make this work like validating the current logged-in user with the list of bookings in an event.

    eg.

    $EM_Booking2 = $EM_Event->get_bookings();
    $events = EM_Events::get( array('scope'=>'future') );
    foreach($events as $event){
     if ($event->event_id == $EM_Event->event_id){
      $bookings = $event->get_bookings();
      foreach($bookings as $booking){
        foreach($EM_Booking2 as $booking2){
          if ($booking->booking_id == $booking2->booking_id ){ //add validation for current loggedin user $booking2->booking_meta is an array which contains all info
           $status =  $booking->booking_status;
           break;
          }
        }
      }
     }
    }
    echo $EM_Event->event_id.' -- '.count($EM_Booking2).' -- '.$status." <<<<<< ";

    Thread Starter ToobHed

    (@toobhed)

    Yes! That did the trick, thank you for the code!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hide Booking Button for Rejected User’ is closed to new replies.