English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Employee  >  Private Area  >  Registration  >  Toggle Subscription Fields

apply_filters( 'vikappointments_toggle_employee_subscription_fields', bool $status, array &$allowed, array $billing, object $employee )

Fires before displaying the billing form to purchase an employee subscription.


Description

Trigger hook to toggle the visibility of certain fields from the Subscriptions page under the Employees Area.

In example, by using the code below, the user profile won't display the VAT Number field anymore.

$allowed['vat'] = false;
// or
unset($allowed['vat']);

Parameters

$status

(bool)  True on success, false otherwise.

&$allowed

(array)  An associative array containing all the allowed fields, where the key is the field identifier and the value represents its visibility.

  • country - the dropdown to pick the country;
  • state - the text field to enter the state/province;
  • city - the text field to enter the city name;
  • address - the text field to enter the address field;
  • zip - the text field to enter the ZIP code;
  • company - the text field to enter the company name;
  • vat - the text field to enter the VAT number.

Assigning new attributes to the array will have no effect.

$billing

(array)  An array holding the currently set billing details.

$employee

(object)  The details of the currently logged-in employee.


Example

The following example hides the Company and VAT Number fields only if they are empty.

/**
 *  Trigger hook to toggle the visibility of certain fields.
 *
 * @param  boolean  $status    True on success, false otherwise.
 * @param  array    &$allowed  An array of allowed fields.
 * @param  array    $billing   An associative array containing the
 *                             value of the billing fields.
 * @param  object   $employee  The employee details.
 */
add_filter('vikappointments_toggle_employee_subscription_fields', function($status, &$allowed, $billing, $employee)
{
    // check whether the Company field is empty
    if (empty($billing['company']))
    {
        // hide field
        $allowed['company'] = false;
    }

    // check whether the VAT Number field is empty
    if (empty($billing['vat']))
    {
        // hide field
        $allowed['vat'] = false;
    }

    return $status;
}, 10, 4);

Changelog

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