English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Site Pages  >  User  >  Toggle Profile Fields

apply_filters( 'vikappointments_toggle_user_profile_fields', bool $status, array &$allowed, object $customer )

Fires before displaying the form to edit the user billing details.


Description

Trigger hook to toggle the visibility of certain fields from the User Profile page. It is possible to access this section from the All Orders page, by clicking the My Profile button.

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

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

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.

  • avatar - the profile image of the user;
  • 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;
  • address2 - the text field to enter an additional information of the address;
  • zip - the text field to enter the ZIP code;
  • company - the text field to enter the company name;
  • vatnum - the text field to enter the VAT number;
  • ssn - the text field to enter the SSN/Fiscal Code.

It is not possible to hide the following fields: name, e-mail and phone number.

Assigning new attributes to the array will have no effect.

$customer

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


Example

The following example hides the SSN field only if 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  object   $customer  The customer details.
 */
add_filter('vikappointments_toggle_user_profile_fields', function($status, &$allowed, $customer)
{
    // check whether the SSN field is empty
    if (empty($customer->ssn))
    {
        // hide field
        $allowed['ssn'] = false;
    }

    return $status;
}, 10, 3);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-10-04
Helpful?