Appointments + hook/action Service Removed

Hi,

I am looking for a hook/action that I can use run my function after an Appointments + Service is removed from the database. I looked in the appointments.php plugin file and saw where you either save or delete the service, but, no hook/action to insert my code so that my changes are preserved when your plugin is updated.

Thanks,

Tin

  • Vinod Dalvi
    • WP Unicorn

    Hi Tin,

    I hope you are well today and thank you for your question.

    You can use any of the appointments hooks like app-appointment-inline_edit-save_data, app_removed, app-appointment-inline_edit-after_save and app-appointment-inline_edit-before_response which you will find in the following appointments plugin file on line numbers 7447, 7462, 7477 and 7498 respectively.

    Appointments plugin file:

    appointments/appointments.php

    Hooks :

    $data = apply_filters('app-appointment-inline_edit-save_data', $data);

    do_action( 'app_removed', $app_id );

    do_action('app-appointment-inline_edit-after_save', ($update_result ? $app_id : $wpdb->insert_id), $data);

    do_action('app-appointment-inline_edit-before_response', ($update_result ? $app_id : $wpdb->insert_id), $data);

    Please advise if you have more questions.

    Best Regards,

    Vinod Dalvi

  • hoangker
    • Site Builder, Child of Zeus

    I tried all those action/filter hooks and none of them fired when I removed a service (cleared the name field) from Appointments + plugin OR added then hit “Save/Update” in the Add New Appointment screen. I added “add_action” to

    -app_removed

    -app-appointment-inline_edit-after_save

    -app-appointment-inline_edit-before_response

    and tried “add_filter” to

    -app-appointment-inline_edit-save_data

    As a simple test to see if my function “delete_msp_service_meta” was firing i tried to run some update code to a service. The update code never ran.

    See below:

    include( content_url() . '/plugins/appointments/appointments.php');
    add_action('app-appointment-inline_edit-save_data','delete_msp_service_meta');
    function delete_msp_service_meta(){

    global $wpdb;

    //check if service with ID = 7 was updated to test action hook
    $wpdb->query("UPDATE '".$wpdb->prefix."'app_services SET name = 'AWESOME' WHERE ID = 7");

    }

    1. Am I calling the actions you specified incorrectly?

    2. Is there some other action I can hook onto by adding an action like:

    add_action('APPOINTMENTPLUSACTION','delete_msp_service_meta');
    function delete_msp_service_meta($service_id) {
    ...
    ...
    SOME CODE
    ...
    }

    thank you,

    Tin

  • hoangker
    • Site Builder, Child of Zeus

    I found the error: my update statement had extra single quote that should not have been there.

    function delete_msp_service_meta(){

    ...
    //check if service with ID = 7 was updated to test action hook
    $wpdb->query("UPDATE '".$wpdb->prefix."'app_services SET name = 'AWESOME' WHERE ID = 7");
    ...
    }

    SUPPOSE TO BE

    function delete_msp_service_meta(){

    ...
    //check if service with ID = 7 was updated to test action hook
    $wpdb->query("UPDATE ".$wpdb->prefix."app_services SET name = 'AWESOME' WHERE ID = 7");
    ...
    }

    thank you for your help!

    Tin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.