English (United Kingdom)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Fields  >  Auto Populate

do_action_ref_array( 'vikrestaurants_auto_populate_custom_fields', array &$data, array $fields, mixed $user )

Fires while binding the values of the custom fields.


Description

Trigger hook to allow external plugins to auto-populate the custom fields with other details that are not supported by default by the user instance.


Parameters

&$data

(array)  Where to inject the fetched data. The keys of the array are equals to the name of the custom fields.

$fields

(array)  An array of custom fields.

$user

(mixed)  The user instance.


Example

/**
 * Trigger hook to allow external plugins to auto-populate the custom fields
 * with other details that are not supported by default by the user instance.
 *
 * @param  mixed    &$data   Where to inject the fetched data.
 * @param  array    $fields  The custom fields list to display.
 * @param  mixed    $user    The details of the user.
 */
add_action('vikrestaurants_auto_populate_custom_fields', function(&$data, $fields, $user) {
    // in case the user holds information about the privacy policy, auto check the field
    $data['privacypolicy'] = (int) ($user->privacypolicy ?? false);
}, 10, 3);

Changelog

Version Description
1.3 Introduced.
Last Update: 2023-12-28
Helpful?