gpb_availability_start
Description
Filter the start date for availability checks. This filter allows you to set an absolute minimum date for bookings. Any dates before this will be marked as unavailable in REST responses and rejected during booking validation. Return null to allow bookings from today onwards (no restriction outside of Availability Windows).
Usage
Filter applied globally to all availability checks
add_filter( 'gpb_availability_start', 'my_custom_function' );Parameters
$start
CarbonImmutable|null
Start date (null = no restriction).
$service
Service
Service object.
$resource_ids
int[]
Resource IDs being checked.
Examples
Restrict bookings to start 3 days from now
Prevent same-day or next-day bookings by requiring at least 3 days advance notice.
add_filter( 'gpb_availability_start', function( $start, $service, $resource_ids ) {
return \Carbon\CarbonImmutable::today()->addDays( 3 );
}, 10, 3 );Restrict bookings to 4 hours from now (time-slot level)
Prevent bookings less than 4 hours in advance, affecting individual time slots. Use ::now() instead of ::today() for datetime precision.
add_filter( 'gpb_availability_start', function( $start, $service, $resource_ids ) {
return \Carbon\CarbonImmutable::now()->addHours( 4 );
}, 10, 3 );Restrict bookings for specific service
Only apply the restriction to a specific service (ID 123).
add_filter( 'gpb_availability_start', function( $start, $service, $resource_ids ) {
if ( $service->get_id() === 123 ) {
return \Carbon\CarbonImmutable::today()->addWeeks( 2 );
}
return $start;
}, 10, 3 );Restrict bookings when specific resource is selected
Apply different restrictions based on which resource is being booked.
add_filter( 'gpb_availability_start', function( $start, $service, $resource_ids ) {
// Premium resource requires 1 week advance notice
if ( in_array( 456, $resource_ids ) ) {
return \Carbon\CarbonImmutable::today()->addWeeks( 1 );
}
return $start;
}, 10, 3 );Since
1.0-alpha-4.2Hook added.1.0-beta-1.1This filter is now used for both date and datetime level checks instead of just date level.