/** * Rebuilds the (ECP) custom/additional field data for the specified event. * * This ensures that events last created/updated under ECP 3.12.x or earlier with * "multichoice"-type additional fields have all the expected entries in the post * meta table. * * @param $event_id */ public function rebuild_fields($event_id) { $fields = array(); foreach ((array) tribe_get_option('custom-fields', array()) as $custom_field) { $value = get_post_meta($event_id, $custom_field['name'], true); // If this is a multichoice field, break it down from a pipe-separated format to an array if (Tribe__Events__Pro__Custom_Meta::is_multichoice($custom_field)) { $value = explode('|', $value); } $fields[$custom_field['name']] = $value; } // Trigger an update Tribe__Events__Pro__Custom_Meta::save_single_event_meta($event_id, $fields); }