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.
1 2 3 4 5 6 7 |
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
1 2 3 4 5 6 7 8 9 10 11 |
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? If not, send us a ticket via helpdesk