Your cart is empty!
Before Populate
apply_filters_ref_array( 'vikappointments_before_auto_populate_custom_fields', bool $status, object &$user )
Fires while binding the values of the user before populating the custom fields.
Description
Trigger hook to allow external plugins to prepare the user details before auto-populating the custom fields.
Parameters
- $status
-
(bool) True on success, false otherwise.
&$user
-
(object) An object holding the user details. By default, the following properties are supported: name, email, phone.
Example
When the user is logged in and the phone number is missing, the plugin searches for a reservation made in the past with the same email address and auto-fills the name and the phone number.
/**
* Trigger hook to allow external plugins to prepare the user data
* before auto-populating the custom fields.
*
* @param bool $status The call status.
* @param mixed &$user The details of the user.
*/
add_action('vikappointments_before_auto_populate_custom_fields', function($status, &$user) {
// check if we have an email and a blank phone number
if ($user->email && !$user->phone) {
// search reservation by mail
$reservation = JModelVAP::getInstance('reservation')->getItem([
'purchaser_mail' => $user->email,
]);
if ($reservation) {
// refresh name and phone number
$user->name = $reservation->purchaser_nominative;
$user->phone = $reservation->purchaser_prefix . $reservation->purchaser_phone;
}
}
}, 10, 2); Changelog
| Version | Description |
|---|---|
| 1.2.11 | Introduced. |
Last Update: 5 days ago
Helpful?