The edited_term_taxonomies WordPress action fires immediately after a term to delete’s children are reassigned a parent.
Usage
add_action('edited_term_taxonomies', 'your_custom_function', 10, 1);
function your_custom_function($edit_tt_ids) {
// your custom code here
}
Parameters
$edit_tt_ids(array) – An array of term taxonomy IDs for the given term.
More information
See WordPress Developer Resources: edited_term_taxonomies
Examples
Log term taxonomies being edited
Log the term taxonomies being edited after their children have been reassigned a parent.
add_action('edited_term_taxonomies', 'log_edited_term_taxonomies', 10, 1);
function log_edited_term_taxonomies($edit_tt_ids) {
error_log(print_r($edit_tt_ids, true));
}
Update term count after reassigning
Update term count for each term taxonomy after reassigning the children.
add_action('edited_term_taxonomies', 'update_term_count_after_reassign', 10, 1);
function update_term_count_after_reassign($edit_tt_ids) {
foreach ($edit_tt_ids as $term_taxonomy_id) {
wp_update_term_count($term_taxonomy_id);
}
}
Send an email notification
Send an email notification when term taxonomies are edited and children are reassigned.
add_action('edited_term_taxonomies', 'send_email_notification', 10, 1);
function send_email_notification($edit_tt_ids) {
$to = '[email protected]';
$subject = 'Term Taxonomies Edited';
$message = 'The following term taxonomies have been edited: ' . implode(', ', $edit_tt_ids);
wp_mail($to, $subject, $message);
}
Clear term cache
Clear the term cache when the term taxonomies are edited and children are reassigned.
add_action('edited_term_taxonomies', 'clear_term_cache', 10, 1);
function clear_term_cache($edit_tt_ids) {
foreach ($edit_tt_ids as $term_taxonomy_id) {
clean_term_cache($term_taxonomy_id);
}
}
Add a custom note
Add a custom note to the term meta when term taxonomies are edited and children are reassigned.
add_action('edited_term_taxonomies', 'add_custom_note', 10, 1);
function add_custom_note($edit_tt_ids) {
foreach ($edit_tt_ids as $term_taxonomy_id) {
$term_id = get_term($term_taxonomy_id)->term_id;
update_term_meta($term_id, 'custom_note', 'Children have been reassigned.');
}
}