Hooks and callbacks
If you need additional customization for your EasyAppointments you can add custom code that will interact with plugin and do custom tasks. There are callbacks and hooks on certain action performed by customer or admin user.
– Frontend callbacks
You can use frontend callback to add custom Javascript
code to perform additional task
Customers form (standard or bootstrap)
When: On creating an appointment
There is event when customer create an appointment called easyappnewappointment
. By listening on that event you can for example trigger Google analytics event. Simple example:
// example document.addEventListener( 'easyappnewappointment', function( event ) { // place here code that will be executed when customer book appointment // ga( 'send', 'event', 'EasyAppointments', 'submit' ); }, false );
When: On selecting time slot in calendar
Event name: easyappslotselects
.
// example document.addEventListener( 'easyappslotselects', function( event ) { // redirect window.location.replace("https://wordpress.org/plugins/easy-appointments/"); }, false );
Note : This should be place inside JavaScript on that particular page.
– Backend callbacks
Ajax backend
When: When customer book appointment
There is a custom WordPress Action
when customer book appointment that can be used for additional data processing. Action is called ea_new_app_from_customer
. For example:
add_action( 'ea_new_app_from_customer', 'custom_callback_function', 10, 2 ); function custom_callback_function( $appointment_id, $appointment_data ) { // do stuff here }
Note : Don’t edit EA plugin code directly instead create your own plugin or put it inside theme that is in use (as child theme).
Email action redirect URL
When: When customer/user click on Email action link (confirm
/ cancel
appointment)
This custom filter allows you add custom redirect page instead of home page that is default. You must provide valid URL address. Action is called ea_confirmed_redirect_url
for conformation and ea_cancel_redirect_url
. For example:
add_filter( 'ea_confirmed_redirect_url', 'custom_confirm_callback_function', 10, 1 ); function custom_confirm_callback_function( $currentUrl) { // do stuff here return ''; } add_filter( 'ea_cancel_redirect_url', 'custom_cancel_callback_function', 10, 1 ); function custom_cancel_callback_function( $currentUrl) { // do stuff here return ''; }
Note : Don’t edit EA plugin code directly instead create your own plugin or put it inside theme that is in use (as child theme).
Alter custom fields filter
There is filter called ea_form_rows
that allows you to override values for custom fields.
add_filter('ea_form_rows', alter_custom_fields); function alter_custom_field($fields) { // do stuff here return $fields; }