public function onAutoPopulateCustomFields( array &$data, array $fields, mixed $user ) : void

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.

Return Value

None.


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.
 *
 * @return  void
 */
public function onAutoPopulateCustomFields(&$data, $fields, $user)
{
    // in case the user holds information about the privacy policy, auto check the field
    $data['privacypolicy'] = (int) ($user->privacypolicy ?? false);
}

Changelog

Version Description
1.9 Introduced.
Last Update: 2023-12-29 14:15
Helpful?