How can I use WordPress hooks for bookings in Amelia
Amelia provides several hooks related to bookings, allowing you to modify booking data or run custom actions when a booking is added, canceled, rescheduled, saved, or processed through post-booking actions. These hooks help you extend Amelia safely without adjusting core plugin files.
Hooks require programming knowledge, and support is limited to general guidance.
Booking added
How do I modify booking data before it is added?
amelia_before_booking_added_filter
Type: filter
Use this filter to modify booking data before it is added. This is triggered when booking through the front end form or when adding a package appointment from the back end.
function example($appointment)
{
// change appointment
return $appointment;
}
add_filter('amelia_before_booking_added_filter', 'example', 10, 1);
How do I run code before a booking is added?
amelia_before_booking_added
Type: action
Runs before a booking is added. This is triggered when booking through the front end form or when adding a package appointment from the back end.
function example($appointment)
{
// do action
}
add_action('amelia_before_booking_added', 'example', 10, 1);
How do I run code after a booking is added?
amelia_after_booking_added
Type: action
Runs after a booking is added. This is triggered when booking through the front end form or when adding a package appointment from the back end.
function example($appointment)
{
// do action
}
add_action('amelia_after_booking_added', 'example', 10, 1);
Booking canceled
How do I run code before a booking is canceled?
amelia_before_booking_canceled
Type: action
Runs before a booking is canceled from the customer panel or via email.
function example($booking)
{
// do action
}
add_action('amelia_before_booking_canceled', 'example', 10, 1);
How do I run code after a booking is canceled?
amelia_after_booking_canceled
Type: action
Runs after a booking is canceled from the customer panel or via email.
function example($booking)
{
// do action
}
add_action('amelia_after_booking_canceled', 'example', 10, 1);
Booking rescheduled
How do I run code before a booking is rescheduled?
amelia_before_booking_rescheduled
Type: action
Runs before a booking is rescheduled from the customer panel or the back end calendar.
function example($oldAppointment, $booking, $bookingStart)
{
// do action
}
add_action('amelia_before_booking_rescheduled', 'example', 10, 3);
How do I run code after a booking is rescheduled?
amelia_after_booking_rescheduled
Type: action
Runs after a booking is rescheduled from the customer panel or the back end calendar.
function example($oldAppointment, $booking, $bookingStart)
{
// do action
}
add_action('amelia_after_booking_rescheduled', 'example', 10, 3);
Post-booking actions
How do I modify data before post-booking actions are triggered?
amelia_before_post_booking_actions_filter
Type: filter
Use this filter to modify booking data before post-booking actions such as sending notifications, adding calendar events, or creating online meetings are triggered.
function example($resultData)
{
// change data
return $resultData;
}
add_filter('amelia_before_post_booking_actions_filter', 'example', 10, 1);
How do I run code before post-booking actions are triggered?
amelia_before_post_booking_actions
Type: action
Runs before post-booking actions such as sending notifications, adding calendar events, or creating online meetings are triggered.
function example($resultData)
{
// do action
}
add_action('amelia_before_post_booking_actions', 'example', 10, 1);
Booking status filters
How do I modify data sent to webhooks?
Type: filter
These filters allow you to modify or extend data sent to webhooks. They are triggered after post-booking actions and before the webhook is sent.
Available filters:
- AmeliaAppointmentBookingCanceledFilter
- AmeliaAppointmentBookingAddedFilter
- AmeliaAppointmentBookingStatusUpdatedFilter
- AmeliaEventBookingCanceledFilter
- AmeliaEventBookingAddedFilter
- AmeliaEventBookingStatusUpdatedFilter
function example($data)
{
return $data;
}
add_filter('AmeliaAppointmentBookingAddedFilter', 'example', 10, 1);
Booking status actions
How do I run code before a webhook is sent?
Type: action
These actions allow you to run custom logic before a webhook is sent. They are triggered after post-booking actions and before the webhook is sent.
Available actions:
- AmeliaAppointmentBookingCanceled
- AmeliaAppointmentBookingAdded
- AmeliaAppointmentBookingStatusUpdated
- AmeliaEventBookingCanceled
- AmeliaEventBookingAdded
- AmeliaEventBookingStatusUpdated
function example($reservation, $bookings, $container)
{
// do action
}
add_action('AmeliaAppointmentBookingCanceled', 'example', 10, 3);
Booking status header filters
How do I modify webhook headers?
Type: filter
These filters allow you to modify data sent in webhook headers before the webhook is sent.
Available filters:
- AmeliaAppointmentBookingCanceledFilterHeader
- AmeliaAppointmentBookingAddedFilterHeader
- AmeliaAppointmentBookingStatusUpdatedFilterHeader
- AmeliaEventBookingCanceledFilterHeader
- AmeliaEventBookingAddedFilterHeader
- AmeliaEventBookingStatusUpdatedFilterHeader
function example_callback($headers, $data)
{
return $headers;
}
add_filter('AmeliaAppointmentBookingAddedFilterHeader', 'example_callback', 10, 2);
Booking saved
How do I modify booking data before it is saved?
amelia_before_appointment_booking_saved_filter
Type: filter
Use this filter to modify booking data before it is saved to the database.
function example($booking, $reservation)
{
// change booking
return $booking;
}
add_filter('amelia_before_appointment_booking_saved_filter', 'example', 10, 2);
How do I run code before a booking is saved?
amelia_before_appointment_booking_saved
Type: action
Runs before a booking is saved to the database.
function example($booking, $reservation)
{
// do action
}
add_action('amelia_before_appointment_booking_saved', 'example', 10, 2);
How do I run code after a booking is saved?
amelia_after_appointment_booking_saved
Type: action
Runs after a booking is saved to the database.
function example($booking, $reservation)
{
// do action
}
add_action('amelia_after_appointment_booking_saved', 'example', 10, 2);