Is it possible to hook a function when a custom taxonomy term (which is not known beforehand), (preferably custom taxonomy child term) is edited/saved, just like the way we can hook into save_post when a post or page is saved?
What I want to do when the taxonomy term is saved:
function generate_pdf($slug) {
wp_remote_get( etc... );
}
EDIT:
It seems that edit_${taxonomy} is the thing that I need, but I can't seem to push the $term_slug into the function:
function pdf_save_magazine($term_id, $tt_id, $taxonomy) {
$term = get_term($term_id, $tt_id);
$term_slug = $term->slug;
wp_remote_get(
'http://url-that-saves-pdf.com/?print='.$term_slug,
array(
'blocking' => false,
'timeout' => 1,
'httpversion' => '1.1'
)
);
}
add_action( 'edit_auteur', 'pdf_save_magazine', $term_id, $tt_id, $taxonomy );
To answer my own question:
This works:
function pdf_save_magazine($term_id, $tt_id, $taxonomy) {
$term = get_term($term_id, $taxonomy);
$term_slug = $term->slug;
wp_remote_get(
'http://url-that-saves-pdf.com/?print='.$term_slug,
array(
'blocking' => false,
'timeout' => 1,
'httpversion' => '1.1'
)
);
}
add_action( 'edit_term', 'pdf_save_magazine', 10, 3 );