How do WordPress hooks work in Amelia
WordPress hooks allow you to extend Amelia without changing its core files. They are useful when you need to adjust logic, display custom messages, create additional workflows, or integrate Amelia with external systems. Hooks are added through user defined functions, and because they sit on top of the plugin’s logic, your customizations remain intact after updates. This makes hooks the safest and most flexible way to modify booking behavior on your site.
Using hooks requires a certain level of programming skills and included support refers only to advice.
What are WordPress filters?
Filters in WordPress let you modify values before Amelia uses them. They can adjust strings, numbers, arrays, or objects and return the changed value back to the plugin. This allows you to override parts of Amelia’s logic without editing any plugin files.
When a filter runs, WordPress applies your function on top of the existing logic, so updates do not affect your customizations. You can find more information about filters in the official WordPress developer documentation.
What are WordPress actions?
WordPress actions allow you to execute your own code at specific moments during Amelia’s workflow. Unlike filters, actions do not return anything.
They are used when you need to trigger a process, log activity, send additional notifications, or connect Amelia to other systems. Actions are called by the plugin at predefined points, and your function runs when that point is reached.
You can learn more about actions in the WordPress developer documentation.
Can I show custom error messages before booking is completed?
Yes. Amelia includes a filter that allows you to display custom messages to customers before they finish a booking. This is useful when specific conditions must be met, such as required metadata, eligibility requirements, or validation rules. When the filter blocks the booking, the message you return will be shown to the customer in place of the final confirmation step.
For example:
function example($appointment)
{
if (1) { // replace "1" with your actual condition
throw new \AmeliaBooking\Domain\Common\Exceptions\CustomException('Custom Message');
}
return $appointment;
}
add_filter('amelia_before_booking_added_filter', 'example', 10, 1);
This custom validation can be used in the following filters and actions:
Filters
- amelia_before_booking_added_filter
- amelia_before_appointment_booking_saved_filter
- amelia_before_event_booking_saved_filter
- amelia_modify_payment_amount
- amelia_before_payment
Actions
- amelia_before_booking_added
- amelia_before_appointment_booking_saved
- amelia_before_event_booking_saved