• Resolved ilanb

    (@ilanb)


    Hi,

    How can I add function when admin disable vendor ?

    I see in vendor.php

    public function make_inactive() {
            $this->update_meta( 'dokan_enable_selling', 'no' );
            $this->change_product_status( 'pending' );
    
            do_action( 'dokan_vendor_disabled', $this->get_id() );
    
            return $this->to_array();
        }

    Best,
    Ilan

    • This topic was modified 1 year ago by ilanb.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @ilanb ,

    You are already in the right direction.

    The hook here is – do_action( 'dokan_vendor_disabled', $this->get_id() );

    You will add your function to this like this –

    add_action( ‘dokan_vendor_disabled’, your_function_here() )`;

    If you are already trying a function but not working then you can share the code with me. I can take a further look at that.

    Thank you 🙂

    Thread Starter ilanb

    (@ilanb)

    Thx Rashed,

    I wrote this, but not sure how get the ID of vendor desactivated:

    function delete_product_pharma_whendisabled( $user_id ) {
        global $wpdb;
        $wpdb->get_results($wpdb->prepare("DELETE FROM {$wpdb->prefix}geo_location WHERE user_id = '%d'", $user_id));
        $wpdb->get_results($wpdb->prepare("DELETE FROM {$wpdb->prefix}postmeta WHERE user_id = '%d'", $user_id));
        $wpdb->get_results($wpdb->prepare("DELETE FROM {$wpdb->prefix}posts_users WHERE user_id = '%d'", $user_id));
    }
    add_filter( 'dokan_vendor_disabled', 'delete_product_pharma_whendisabled');
    alamgircsebd

    (@alamgircsebd)

    Hello @ilanb

    you using add_filter which is wrong. here you should use add_action

    use this codes, here different only add_filter to add_action

    function delete_product_pharma_whendisabled( $user_id ) {
        global $wpdb;
        $wpdb->get_results($wpdb->prepare("DELETE FROM {$wpdb->prefix}geo_location WHERE user_id = '%d'", $user_id));
        $wpdb->get_results($wpdb->prepare("DELETE FROM {$wpdb->prefix}postmeta WHERE user_id = '%d'", $user_id));
        $wpdb->get_results($wpdb->prepare("DELETE FROM {$wpdb->prefix}posts_users WHERE user_id = '%d'", $user_id));
    }
    add_action( 'dokan_vendor_disabled', 'delete_product_pharma_whendisabled' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘dokan_vendor_disabled add function when called’ is closed to new replies.