Created
September 8, 2022 15:09
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
/* | |
* This function allows you to set an array of fields to be excluded from the CSV. | |
* The fields_in_order array allows you to set the specific order for the fields you want, any additional fields stil | |
* included in the CSV will be appended to the end of the fields | |
*/ | |
function tw_ee_espresso_reg_report_filter_columns_exclude_and_order($csv_row, $registration_db_row) | |
{ | |
// Add the fields you wish to exclude from the CSV here. | |
$fields_to_exclude_from_csv = [ | |
// These excluded fields are an example of how to remove fields, your list will be different. | |
__('Payment Date(s)', 'event_espresso'), | |
__('Payment Method(s)', 'event_espresso'), | |
__('Gateway Transaction ID(s)', 'event_espresso'), | |
__('Check-Ins', 'event_espresso') | |
]; | |
foreach ($fields_to_exclude_from_csv as $single_field_to_exclude) { | |
// Remove all of the fields we want to exclude from the CSV. | |
unset($csv_row[$single_field_to_exclude]); | |
} | |
// Set the field order you want to use in this array. | |
$fields_in_order = [ | |
__('Last Name', 'event_espresso'), | |
__('First Name', 'event_espresso'), | |
__('Email Address', 'event_espresso'), | |
]; | |
// Set the value for each of the array elements to an empty string. | |
// This is incase any of the above questions do not exist in the current registration's questions, | |
// they still need to be included in the row but the value should be nothing. | |
$fields_in_order = array_fill_keys(array_keys(array_flip($allowed_fields_in_order)), ''); | |
// Use array_merge to create a new array using the field order we set and amend any additional | |
// fields to the end of the CSV. | |
$filtered_csv_row = array_merge($fields_in_order, $csv_row); | |
// Return the filtered CSV. | |
return $filtered_csv_row; | |
} | |
add_filter('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', 'tw_ee_espresso_reg_report_filter_columns_exclude_and_order', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment