Your cart is empty!
Before Build
apply_filters( 'vikappointments_before_build_timeline', bool $show, mixed $search, string $date, int $people, int $id )
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
- $show
-
(bool) False to prevent the timeline from showing.
- $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.
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 boolean $show False to hide the timeline.
* @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.
*/
add_filter('vikappointments_before_build_timeline', function($show, $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'));
}
// propagate default status
return $show;
}, 10, 5);
Changelog
Version | Description |
---|---|
1.2 | Introduced. |
Last Update: 2021-10-05
Helpful?