Update: Is there a way to test if a user has at least one booking that is NOT a cancelled booking? This is the key.
Based on code from templates > my-bookings.php, there is a way to test if a user has a booking.
global $wpdb, $current_user, $EM_Notices, $EM_Person;
if( is_user_logged_in() ):
$EM_Person = new EM_Person( get_current_user_id() );
$EM_Bookings = $EM_Person->get_bookings();
$bookings_count = count($EM_Bookings->bookings);
if($bookings_count > 0){
//Get events here in one query to speed things up
$event_ids = array();
foreach($EM_Bookings as $EM_Booking) {
$event_ids[] = $EM_Booking->event_id;
}
}
You can then use ‘$bookings_count > 0’ or whatever you need to test whether a user has a booking.
Another issue regarding cancellations comes up though. If a user cancels a booking they make through the My Bookings page, the system still counts this Cancelled booking as a booking. In other words, the $bookings_variable doesn’t go back to 0 if a user cancels a booking. It only goes to 0 when an admin deletes the booking completely through the admin.
So again:
Is there a way to test if a user has at least one booking that is NOT a cancelled booking? This is the key.