gpb_pre_status_transition
Description
Filter whether a booking status transition should be allowed.
Usage
Filter applied globally
add_filter( 'gpb_pre_status_transition', 'my_custom_function' );
Parameters
$allowed
bool
Whether the transition is allowed.
$new_status
string
The new status being transitioned to.
$old_status
string
The current status being transitioned from.
$booking
GP_BookingsBooking
The booking object.
Examples
Prevent transitions to cancelled status
add_filter('gpb_pre_status_transition', function($allowed, $new_status, $old_status, $booking) {
if ($new_status === 'cancelled') {
return false;
}
return $allowed;
}, 10, 4);
Log all status transitions
add_filter('gpb_pre_status_transition', function($allowed, $new_status, $old_status, $booking) {
error_log("Booking {$booking->get_id()} transitioning from {$old_status} to {$new_status}");
return $allowed;
}, 10, 4);
Since
1.0-alpha-1.0
Hook added.