Your cart is empty!
Before Build
public function onBeforeBuildTimeline(mixed $search, string $date, int $people, int $id) : bool
Fires before constructing the object wrapping the timeline.
Description
Trigger hook to check whether the availability timeline should be displayed or not. Useful in example to avoid showing the timeline to guest users.
NOTE: throw an exception to prompt a message to the front-end user to explain why the timeline is not visible.
Parameters
- $search
-
(VAPAvailabilitySearch) The availability search handler, holding all the query details.
- $date
-
(string) The UTC date in military format.
- $people
-
(int) The number of attendees.
- $id
-
(int) The selected appointment ID, if any.
Return Value
Boolean. False to prevent the timeline from showing.
Example
The example hides the timeline for the users that aren't logged in.
/**
* Trigger hook to check whether the availability timeline should be displayed
* or not. Useful in example to avoid showing the timeline to guest users.
*
* Throw an exception to display an error message to the front-end user.
*
* @param mixed $search The search handler.
* @param string $date The UTC date in military format.
* @param integer $people The number of participants.
* @param integer $id The selected appointment ID.
*
* @return boolean False to hide the timeline.
*/
public function onBeforeBuildTimeline($search, $date, $people, $id)
{
// check whether the user is logged in
if (!VikAppointments::isUserLogged())
{
// we have a guest user, show error message and hide the timeline
throw new Exception(__('You must be logged in', 'my-plugin'));
}
return true;
}
Changelog
Version | Description |
---|---|
1.7 | Introduced. |
Last Update: 2021-10-05 17:28
Helpful?