Delete hook incompatibility with delete function in wordpress?

I have this action/hook:

add_action( 'before_delete_post', 'my_delete_function' );
 function my_delete_function($post_id) { 
    global $wpdb;
    $achievement = get_the_category($post_id); 
    $h = $achievement[0]->cat_ID; 
    $s = ''.str_replace('"', '', $h);
   if ( $s == 6 || $s == 5){
        $wpdb->query("DELETE FROM wp_votes WHERE post = ".$post_id) or die(mysql_error());

    }
}

The above works great when I am deleting posts from the admin. However, when the wp_delete_post() is called, the above function isnt called.

Read More

How can I make the action work with the delete function?

Related posts

Leave a Reply

1 comment