English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Appointments  >  Availability  >  Fetch Service Employees

apply_filters( 'vikappointments_fetch_service_available_employees', array $employees, mixed $search, string $date )

Fires while checking whether the specified service is able to host an appointment.


Description

Trigger hook to use a custom method to load the supported employees without having to use a direct query.

The plugins will have to return an array of employee IDs.

NOTE: calling $search->isServiceAvailable() will result in recursion.


Parameters

$employees

(array|null)  An array of employee IDs. At the first execution of the filter, the return value might be null.

$search

(VAPAvailabilityImplementor)  The instance used to check the availability.

$date

(string)  The check-in date (UTC).


Example 

/**
 * Trigger hook to use a custom method to load the supported employees
 * without having to use a direct query. The plugins will have to return
 * an array of employee IDs.
 *
 * @param  string  $employees  The list of employees.
 * @param  mixed   $search     The availability search instance.
 * @param  string  $date       The check-in date (UTC).
 */
add_filter('vikappointments_fetch_service_available_employees', function($employees, $search, $date)
{
    // init return value first
    if (is_null($employees))
    {
        $employees = [];
    }

    // always include employees #1, #2 and #3
    return array_merge($employees, [1, 2, 3]);
}, 10, 3);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-08-23
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information