Impostazioni Override
apply_filters( 'vikappointments_override_employees_area_setting', mixed $value, string $role, mixed $setting, mixed $handler )
Fires while fetching a setting for the employees area.
Description
Trigger hook to allow external plugins to override a specific setting of the employees area.
Here's the full list of settings (roles) that can be overwritten at runtime:
config.registerconfig.signup.statusconfig.signup.groupconfig.servicesprofile.manageservice.createservice.manageservice.overrideservice.assignservice.removeservice.maxpayment.managecoupon.managefield.manageworktime.managelocation.managereservation.createreservation.managereservation.confirmreservation.removereservation.notify
Parameters
- $value
-
(mixed) The value to return.
- $role
-
(string) The identifier of the role to override.
- $setting
-
(mixed) The default setting value.
- $handler
-
(VAPEmployeeAuth|null) The employee wrapper instance or null.
Example
The example below explains how to have dynamic settings, which may vary depending on the purchased subscription plan. In this case, we are going to increase the maximum number of services that can be created, depending on the latest purchased subscription. In example:
- Basic (ID #1) - 5 services
- Advanced (ID #2) - 10 services
- Premium (ID #3) - 15 services
/**
* Trigger event to allow external plugins to override a specific setting
* of the employees area.
*
* @param mixed $value The value to return.
* @param string $role The role to check.
* @param mixed $setting The default setting value.
* @param mixed $handler The employee wrapper instance or null.
*/
add_filter('vikappointments_override_employees_area_setting', function($value, $role, $setting, $handler)
{
if ($role !== 'service.max')
{
return $value;
}
$dbo = JFactory::getDbo();
// fetch the latest purchased subscription
$q = $dbo->getQuery(true)
->select($dbo->qn('id_subscr'))
->from($dbo->qn('#__vikappointments_subscr_order'))
->where($dbo->qn('id_employee') . ' = ' . (int) $handler->id)
->where($dbo->qn('status') . ' IN (\'P\', \'C\')')
->order($dbo->qn('id') . ' DESC');
$dbo->setQuery($q, 0, 1);
$dbo->execute();
if ($dbo->getNumRows())
{
switch ((int) $dbo->loadResult())
{
// basic
case 1:
$value = 5;
break;
// advanced
case 2:
$value = 10;
break;
// premium
case 3:
$value = 15;
break;
}
}
return $value;
}, 10, 4); Changelog
| Version | Description |
|---|---|
| 1.2 | Introduced. |
Ultimo aggiornamento: 2021-10-08
Utile?