0

Trying to make a system whereby a function is called upon an admin changing the taxonomy category (term - if i understand correcrtly) of a custom post type.

I thought the action tag "edit_category" would do this, but doesnt seem to work:

add_action('edit_category_form', 'myFunction');

Any ideas?

Thanks!

2 Answers 2

1

'set_object_terms' is probably the hook you want. It gets passed the following: post_id, terms, term_taxonomy ids, taxonomy, append, old term_taxonomy ids.

You can use the post_id and taxonomy params to determine if its the post type and taxonomy you want to hook into, and then check if term_taxonomy_ids differs from the old term_taxonomy_ids to decide whether anything was changed.

1

This worked for me:

add_action('set_object_terms', 'do_stuff_when_taxo_changes', 10, 1);

function do_stuff_when_taxo_changes($post_id) {

    // Do Stuff

}
1
  • I'd use add_action( 'set_object_terms', 'do_stuff_when_taxo_changes', 10, 6 );, because that way you'll have access to the full list of parameters.
    – Pat J
    Oct 12, 2016 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.