In this function the earliest hook is “delete_term_taxonomy”. However, it seems like the relationships are already deleted before this hook fires.
According to the source, 'delete_term_taxonomy'
runs just before deletion and 'deleted_term_taxonomy'
runs just after. There are other things going on before this code, like the child relationships are changed.
do_action( 'delete_term_taxonomy', $tt_id );
$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
do_action( 'deleted_term_taxonomy', $tt_id );
Are you sure you were not using 'deleted_term_taxonomy'
by mistake?
Is there any other hook I can use?
If the taxonomy is hierarchical, 'edit_term_taxonomies'
and 'edited_term_taxonomies'
run first:
do_action( 'edit_term_taxonomies', $edit_tt_ids );
$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
do_action( 'edited_term_taxonomies', $edit_tt_ids );