The CSV importer tool of The Events Calendar has a lot of pre-set fields that you can use. They cover all the basic data, that you would need to add events to your calendar.

If you have some custom data that is not included in the basic set, then – like for most things – there is a snippet you can use.

In the below example we add three columns. One for the event status, and two more for custom data.

The only thing you need to do is define the meta key and the label for the data in the $custom_import_data array. The snippet takes care of the rest.

class TEC_CSV_Import_Custom_Metadata {
	/**
	 * Define your custom data here.
	 * key   => the meta key that will be used to save the data
	 * value => The label of the data used for column mapping
	 *
	 * @var string[]
	 */
	public $custom_import_data = [
		'_tribe_events_status' => 'Event Status',
		'meta_key_1'           => 'Meta Data 1',
		'meta_key_2'           => 'Meta Data 2',
	];

	/**
	 * Constructor.
	 */
	public function __construct() {
		add_filter( 'tribe_events_importer_event_column_names', [ $this, 'add_column_name' ] );

		add_filter( 'tribe_events_csv_import_event_additional_fields', [ $this, 'process_custom_data' ] );

		add_action( 'tribe_events_update_meta', [ $this, 'save_custom_data' ], 10, 3 );
	}

	/**
	 * Add the field name to the dropdown.
	 *
	 * @param array<string|string> $column_names An array of column names for event import.
	 *
	 * @return string[]
	 */
	public function add_column_name( $column_names ) {
		foreach ( $this->custom_import_data as $key => $value ) {
			$column_names[ $key ] = $value;
		}

		return $column_names;
	}

	/**
	 * Make sure that the added column gets processed on import.
	 *
	 * @return array
	 */
	function process_custom_data() {
		// key (meta field name, table column name) => CSV column ID, the key from the above function.
		$extra_fields[ 'tec_import_event_status' ] = 'tec_import_event_status';

		foreach ( $this->custom_import_data as $key => $value ) {
			$extra_fields[ $key ] = $key;
		}

		return $extra_fields;
	}

	/**
	 * Save metadata in database.
	 *
	 * @param int     $event_id The event ID we are modifying meta for.
	 * @param array   $data     The meta fields we want saved.
	 * @param WP_Post $event The event itself.
	 *
	 * @return void
	 */
	function save_custom_data( $event_id, $data, $event ) {
		foreach ( $this->custom_import_data as $key => $value ) {
			if ( isset( $data[ $key ] ) && $data[ $key ] != '' ) {
				update_post_meta( $event_id, $key, esc_html( $data[ $key ] ) );
			}
		}
	}
}

new TEC_CSV_Import_Custom_Metadata();

Note, that the Event Status in this example is hooked up to the event status dropdown that comes with The Events Calendar. This supports the following 3 statuses out of the box, which are also supported by schema.org:

  • Scheduled (default)
  • Canceled
  • Postponed

If you’d like to set up custom event statuses, then check out this article.