Getting old term value with edited_{$taxonomy} | Hook

You would need to use a hook before the term is updated, both edit_{$taxonomy} and edited_{$taxonomy} fire after, though you still may be able to use Term Cache I wouldn’t consider it reliable. Maybe try using the wp_update_term_data hook instead which gives you the current term before it gets updated, and the data that will be updated. You’ll need to manually check for your taxonomy but it should work:

/**
 * @param Array $update_data    - array( 'name' => 'New Term Name', 'description' => 'New Description' )
 * @param Integer $term_id      - The term ID to update
 * @param String $taxonomy      - The Taxonomy the term belongs to
 *
 * @return Array $update_data
 */
function wpse270998( $update_data, $term_id, $taxonomy ) {

    if( 'um_user_tag' !== $taxonomy ) {
        return $update_data;
    }

    $term = get_term( $term_id, $taxonomy );
    return $update_data;
}
add_filter( 'wp_update_term_data', 'wpse270998', 10, 3 );

Leave a Comment