Skip to content

Instantly share code, notes, and snippets.

@altuno
Created December 1, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altuno/71b100d90ebaf2b8da256ecdef5f421b to your computer and use it in GitHub Desktop.
Save altuno/71b100d90ebaf2b8da256ecdef5f421b to your computer and use it in GitHub Desktop.
Allowed fields function:
//------------------------------------------------------------------------
/*
* This function allows you to set an array of 'allowed' fields that will be output to the registration CSV.
* The order in which they are set in the 'allowed_fields_in_order' array is the order that will be used by the CSV itself.
*/
function tw_ee_espresso_reg_report_filter_columns_ordered($csv_row, $registration_db_row)
{
// Set the allowed fields here and also set them in the order you want them to be displayed within the CSV
$allowed_fields_in_order = array(
__('Event', 'event_espresso'),
__('Transaction ID', 'event_espresso'),
__('Attendee ID', 'event_espresso'),
__('Registration ID', 'event_espresso'),
__('Time registration occurred', 'event_espresso'),
__('Unique Code for this registration', 'event_espresso'),
__('Count of this registration in the group registration ', 'event_espresso'),
__('Registration\'s share of the transaction total', 'event_espresso'),
__('Currency', 'event_espresso'),
__('Registration Status', 'event_espresso'),
__('Transaction Status', 'event_espresso'),
__('Transaction Amount Due', 'event_espresso'),
__('Amount Paid', 'event_espresso'),
__('Payment Date(s)', 'event_espresso'),
__('Payment Method(s)', 'event_espresso'),
__('Gateway Transaction ID(s)', 'event_espresso'),
__('Check-Ins', 'event_espresso'),
__('Ticket Name', 'event_espresso'),
__('Datetimes of Ticket', 'event_espresso'),
__('First Name', 'event_espresso'),
__('Last Name', 'event_espresso'),
__('Email Address', 'event_espresso'),
__('Address Part 1', 'event_espresso'),
__('Address Part 2', 'event_espresso'),
__('City', 'event_espresso'),
__('State', 'event_espresso'),
__('Country', 'event_espresso'),
__('ZIP/Postal Code', 'event_espresso'),
__('Phone', 'event_espresso'),
__('Total Taxes', 'event_espresso'),
__('Event Categories', 'event_espresso'),
__('Author', 'event_espresso'),
__('Tag', 'event_espresso'),
__('Venue', 'event_espresso'),
__('Transaction Promotions', 'event_espresso'),
);
// Flip the array so the values are now the keys.
$allowed_fields_in_order = array_flip($allowed_fields_in_order);
// 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.
$allowed_fields_in_order = array_fill_keys(array_keys($allowed_fields_in_order), '');
// Sets $filtered_csv_row to only contain the 'allowed' fields.
$filtered_csv_row = array_intersect_key(
$csv_row,
$allowed_fields_in_order
);
// Now lets set $filtered_csv_row to use the same custom order we set $allowed_fields_in_order to
$filtered_csv_row = array_merge($allowed_fields_in_order, $filtered_csv_row);
return $filtered_csv_row;
}
add_filter('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', 'tw_ee_espresso_reg_report_filter_columns_ordered', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment