Last modified: February 4, 2018

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

Location: 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 );
     

Note : This should be place inside JavaScript on that particular page.

– Backend callbacks

Location: 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).