Hook to execute after deleting a Custom Taxonomy

I need to execute a portion of code after each: Add / Edit / delete a custom taxonomy .
For creation / edition it works well, but for deletion non :

    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 );

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Changes argument numbers 2 to 4 as below

add_action( 'delete_product_category', array ( $this , 'term_delete_success' ), 10, 4);

Here is the reference function.

You may find detail on wordpress codex

More info

do_action( "delete_{$taxonomy}", int $term, int $tt_id, mixed $deleted_term, array $object_ids )

Method 2

I changed the hook to this :

add_action( 'delete_term_taxonomy', array ( $this , 'term_delete_success' ), 9, 1 );

it resolved my issue.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x