当编辑/保存自定义分类术语(事先不知道)(最好是自定义分类术语子术语)时,是否可以挂钩函数,就像我们在帖子或页面是挂钩到save_post的方式一样保存?
保存分类术语时我想做什么:
function generate_pdf($slug) {
wp_remote_get( etc... );
}
修改
似乎编辑_ $ {taxonomy}是我需要的东西,但我似乎无法将$ term_slug推送到函数中:
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 );
答案 0 :(得分:6)
回答我自己的问题:
这有效:
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 );