add_action(‘save_post_event_listing’, function ($post_id) {
// Prevent infinite loops and autosave interference
if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) return;
if (wp_is_post_revision($post_id)) return;
// 1. Get raw tag string (e.g. “music, party, kids”)
$raw = get_post_meta($post_id, ‘_event_tag’, true);
if (empty($raw)) return;
// 2. Sanitize and split into tag names
$tag_names = array_filter(array_map(‘trim’, explode(‘,’, $raw)));
// 3. Convert tag names to term IDs (insert if needed)
$term_ids = [];
foreach ($tag_names as $tag_name) {
$term = term_exists($tag_name, ‘event_tag’);
if (!$term) {
$term = wp_insert_term($tag_name, ‘event_tag’);
}
if (!is_wp_error($term) && isset($term[‘term_id’])) {
$term_ids[] = (int) $term[‘term_id’];
}
}
if (!empty($term_ids)) {
// 4. Update the ACF taxonomy field using field key (returns Term IDs)
update_field(‘field_68596b5168d38’, $term_ids, $post_id);
}
});
To register for this event email your details to ryanleow@hotmail.com
To register for this event email your details to ryanleow@hotmail.com