Hook when category is added to post

You may want to try:

do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);

You can find it under this Docs and the action is located at wp-includes/taxonomy.php

add_action('set_object_terms','wpse5123_set_object_terms',10,4);

function wpse5123_set_object_terms($object_id, $terms, $tt_ids, $taxonomy){
       if($taxonomy == 'category'){
           echo '<pre>';
           print_r($terms);
           echo '</pre>';
           exit;
       }
}

The code above isn’t tested but I think you get the point.

Leave a Comment