Your cart is empty!
Before Populate
public function onBeforeAutoPopulateCustomFields(object &$user) : void
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
- &$user
-
(object) An object holding the user details. By default, the following properties are supported: name, email, phone.
Return Value
None.
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 mixed &$user The details of the user.
*
* @return void
*/
public function onBeforeAutoPopulateCustomFields(&$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;
}
}
}
Changelog
| Version | Description |
|---|---|
| 1.7.4 | Introduced. |
Last Update: 4 hours ago.
Helpful?