How perform action during add/edit/delete category using hooks : wordpress

Hello Friends!!
If you want perform any action during add/edit/delete category/taxonomy without changing in wordpress core files then you can do it using wordpress hooks . You will only need to add given blow function in your theme function file, no need to edit

/** Call function during create new category/taxonomy */
add_action('create_term','wp_custom_save_taxonomy');
function wp_custom_save_taxonomy($term_id) {
print_r($_POST); // add action here
}
/** Call function during edit category/taxonomy */
add_action('edit_term','wp_custom_edit_taxonomy');
function wp_custom_edit_taxonomy($term_id) {
print_r($_POST); // add action here
}
/** Call function during delete category/taxonomy */
add_action('delete_term_taxonomy','wp_custom_delete_taxonomy');
function wp_custom_delete_taxonomy($term_taxonomy_id) {
       global $wpdb; // add action here
}

I hope you will enjoy wordpress hooks magic!!

Leave a Reply

Your email address will not be published. Required fields are marked *