Filters in WordPress are a type of callback function that can be defined by the user and are applied to certain values – strings, integers, objects, etc. It is a simple way to adjust code output without actually having to modify the code. Essentially, you add a given function on top of an existing one, to override the logic. Then, when the plugin is updated later, you won’t lose any of your changes.
You can get a detailed description of WordPress hooks here in WP Codex.
WordPress Actions provide a convenient way to “hook” into different plugins without changing their code. Basically, “actions” are user-defined functions, assigned to certain labels, that are called by the plugin core at defined moments of its execution.
Unlike filters, actions do not return any data, they are simply executed.
You can read more about using WordPress actions and assigning your functions to actions in WordPress Codex. Here, we will provide a list of actions defined in the Amelia plugin that you can use to customize it for your needs.
New - You can now show a custom error message to customers before they complete a booking. This is useful if certain conditions aren’t met — for example, if a required field is missing or a specific rule hasn’t been followed.
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);
You can use this custom validation 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