我需要在每个之后执行一部分代码:添加/编辑/删除自定义分类法。对于创建/编辑,它运行良好,但对于删除非:
add_action( \'edited_product_category\', array ( $this , \'term_edit_success\' ), 10, 2 );
add_action( \'create_product_category\', array ( $this , \'term_create_success\' ), 10, 2 );
add_action( \'delete_product_category\', array ( $this , \'term_delete_success\' ), 10, 2 );
最合适的回答,由SO网友:Younes.D 整理而成
我将挂钩改为:
add_action( \'delete_term_taxonomy\', array ( $this , \'term_delete_success\' ), 9, 1 );
它解决了我的问题。
SO网友:Muhammet DÜLGER
Changes argument numbers 2 to 4 as below
add_action( \'delete_product_category\', array ( $this , \'term_delete_success\' ), 10, 4);
这里是参考函数。
您可以在wordpress codex上找到详细信息
More info
do_action( "delete_{$taxonomy}", int $term, int $tt_id, mixed $deleted_term, array $object_ids )