$region_id]);
foreach ($meetings as $meeting) {
wp_update_post(['ID' => $meeting['id']]);
}
// delete this region and reassign its locations to another region
if (!empty($_POST['delete_and_reassign'])) {
$location_ids = get_posts([
'post_type' => 'tsml_location',
'numberposts' => -1,
'fields' => 'ids',
'tax_query' => [
[
'taxonomy' => 'tsml_region',
'terms' => intval($region_id),
],
],
]);
// assign new region to each location
foreach ($location_ids as $location_id) {
wp_set_object_terms($location_id, intval($_POST['delete_and_reassign']), 'tsml_region');
}
// delete term
wp_delete_term($region_id, 'tsml_region');
// redirect to regions list
wp_safe_redirect(admin_url('edit-tags.php?taxonomy=tsml_region&post_type=tsml_location'));
}
},
10,
2
);