I think this could be handled with wp_set_object_terms()
call on save_post_{$post->post_type}
action. Using the post type specific action you’ll only target your cpt.
The action provides bool $update
parameter, which can be used to check, if the action is fired for a new post or on update.
Passing an empty $terms
value to the function clears any existing terms of the set taxonomy, which saves you the effort of first checking, if any terms exist.
// update action to match your custom post type
add_action( 'save_post_{$post_type}', 'my_clear_post_locations_on_update', 10, 3 );
function my_clear_post_locations_on_update(int $post_ID, WP_Post $post, bool $update) {
// only affect updates, not new post saves
if ( ! $update ) {
return;
}
// nuke taxonomy terms from the post
// store return value in a variable for checking the result, if interested
wp_set_object_terms(
$post_ID, // object ID
array(), // terms
'location', // taxonomy
false // append
);
}
P.S. Replace the empty array with a term slug, single term ID, or array of either term slugs or IDs, if you want to force term/s on the post.