Very simple, where would I hook/filter to alter the users selection of terms when they save a post (Update or Add)?
I need to hook in all instances; such as when saving a post via AJAX, saving when JavaScript is disabled and a normal POST is done and when posts are saved via quick edit.
It is always 'save_post'
(or 'wp_insert_post'
immediately after this). In $_POST['tax_input']
you will find all the terms for all taxonomies associated with the current post.
Example:
'tax_input' =>
array (
'location' =>
array (
0 => '0',
),
),
To change the terms you have to call wp_set_post_terms( $post_ID, $tags, $taxonomy );
manually, just changing these values will not work because they are set when the actions fire.
For an existing post that is updated you can hook into 'edit_post'
and 'post_updated'
.
Parameters for all these actions are $post_ID, $post
in this order. For 'post_updated'
there is a small change: $post_ID, $post_after, $post_before
.