Import Additional Fields Using Hooks
Last Updated: February 2, 2022
In order to support custom Event field columns in the CSV file, you’ll need to add some code to your site. The code tells EventON to expect some additional columns during the import process.
This tutorial is intended for advanced users and you might have to reach out to your developer for some help in adding this code. The code should be added to your theme’s functions.php file.
add_filter('evocsv_additional_csv_fields', 'evocsv_function1', 10, 1); function evocsv_function1($array){ $array['newfield'] = 'newfield'; return $array; }
Action to perform to import the new data from CSV file into event
add_action('evocsv_save_event_custom_data','evocsv_function2', 10, 3); function evocsv_function2($eventID, $postdata, $field){ if($field == 'newfield' && isset( $postdata[$field]) ){ update_post_meta($eventID, '_field_var_name', $postdata[$field]); } }
In the CSV file create a new column with the header matching the field name eg. newfield and enter the values that you want to import
The new field column would look like the above image when the CSV file is opened in Microsoft Excel. The CSV file column name must match the field name set in the above example. (newfield)
Requires CSV importer version 1.0 and or newer.
Did this article help you?