English (United Kingdom)

apply_filters_ref_array( 'vikappointments_build_employee_search_query', bool $status, mixed &$queryarray &$options )

Fires while loading the employee to display.


Description

Trigger hook to manipulate at runtime the query used to load the employee to display under the Employee Details page in the front-end.

Third party plugins can extend the query by applying further conditions or selecting additional data.


Parameters

$status

(bool)  True on success, false otherwise.

&$query

(mixed)  Either a query builder object or a plain string.

&$options

(array)  An array of options.

  • id_employee - the ID of the employee to load;
  • id_service - the ID of the service assigned to the specified employee.

Example

The example below auto-unpublishes the employee with ID #5 when we currently are in Summer.

/**
 * Trigger hook to manipulate the query at runtime. Third party plugins
 * can extend the query by applying further conditions or selecting
 * additional data.
 *
 * @param  boolean  $status    True on success, false otherwise.
 * @param  mixed    &$query    Either a query builder or a query string.
 * @param  array    &$options  An array of options.
 */
add_filter('vikappointments_build_employee_search_query', function($status, &$query, &$options)
{
    // check if we are trying to fetch a specific employee
    if ($options['id_employee'] != 5)
    {
        return true;
    }

    // get current month
    $mon = (int) JHtml::_('date', 'now', 'n');

    // check if we are in Summer
    if (in_array($mon, [6, 7, 8]))
    {
        // quick statement to always return no rows
        $query->where(0);
    }

    return true;
}, 10, 3);

Changelog

Version Description
1.2 Introduced.
Last Update: 2022-01-28
Helpful?
See Also: