gpb_booking_operation_restrictions

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Let administrators bypass the reschedule deadline
  5. Since

Description

Filter the restrictions that apply to a booking operation. Return null to allow the operation, or an array with a type key (and, for deadline restrictions, a deadline key) to restrict it. This is the single source of truth for whether an operation is permitted, so it can be used to relax or tighten the default rules.

Usage

Filter applied globally

add_filter( 'gpb_booking_operation_restrictions', 'my_custom_function' );

Parameters

$operation string

The operation (‘reschedule’ or ‘cancel’).

$booking GP_BookingsBooking

The booking object.

Examples

Let administrators bypass the reschedule deadline

add_filter('gpb_booking_operation_restrictions', function($restrictions, $operation, $booking) {
    if (
        $operation === 'reschedule'
        && ($restrictions['type'] ?? null) === 'deadline'
        && GFCommon::current_user_can_any( gpb_get_admin_capability( 'dashboard' ) )
    ) {
        return null;
    }
    return $restrictions;
}, 10, 3);

Since

  • 1.0-beta-2.12 Hook added.