We have a problem adding custom registration questions to custom csv event registrations report.
Here is how our report is modified:
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_reg_report_filter_columns', 10, 2);
function espresso_reg_report_filter_columns( $csv_row, $registration_db_row ) {
$filtered_csv_row = array_intersect_key(
$csv_row,
array_flip(
array(
__( 'Registration Status', 'event_espresso' ),
'radio',
)
)
);
return $filtered_csv_row;
}
// add event title to csv report
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_add_event_title', 10, 2);
function espresso_add_event_title( $reg_csv_array, $reg_row ) {
$reg_csv_array[ __( 'Event Title', 'event_espresso' ) ] = $reg_row['Event_CPT.post_title'];
return $reg_csv_array;
}
// add registration date and time to csv report
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_add_date', 10, 2);
function espresso_add_date( $reg_csv_array, $reg_row ) {
$reg_csv_array[ __( 'Registration Time', 'event_espresso' ) ] = $reg_row['Registration.REG_date'];
return $reg_csv_array;
}
// we keep adding data to the report the same way
// HERE WE NEED TO ADD CODE FOR ADDING CUSTOM QUESTION ANSWER
// here we exclude fields from the report that we don't need
function ee_exclude_custom_fields_from_export($reg_csv_array, $reg_row) {
$fields_to_exclude_from_csv = array(
//Add the fields you wish to exclude from the CSV here.
//These excluded fields are an example of how to remove fields, your list will be different.
'Transaction ID[TXN_ID]',
'Attendee ID[ATT_ID]',
'Registration ID[REG_ID]',
'Payment Date(s)',
'Payment Method(s)',
'Gateway Transaction ID(s)',
'Check-Ins',
'Address Part 1[ATT_address]',
'Address Part 2[ATT_address2]',
'City[ATT_city]',
'State[STA_ID]',
'Country[CNT_ISO]',
'ZIP/Postal Code[ATT_zip]',
'Phone[ATT_phone]',
);
foreach( $fields_to_exclude_from_csv as $single_field_to_exclude ) {
//For each field within $fields_to_exclude_from_csv, check if that value is within the array.
if ( array_key_exists( $single_field_to_exclude, $reg_csv_array )) {
//If the field is set remove it from the array.
unset( $reg_csv_array[$single_field_to_exclude] );
}
}
return $reg_csv_array;
}
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'ee_exclude_custom_fields_from_export', 100, 2 );
That makes the CSV have 1 Constant column and any others with ‘radio’ in the name.
The next 2 add a ‘Event Title’ and ‘Registration Time’ column and the last function basically does nothing because the first function removed everything.
You question is about adding custom registration questions to the CSV, however, the CSV already has those included and your custom functions are removing them, to then try adding them in again?
I would start by removing the first function from above so that you get all values in the CSV. Then use the ee_exclude_custom_fields_from_export function to remove the additional fields you don’t want to be included.
Or if you can provide more details on what you are trying to do with the CSV I can advise further.
Viewing 1 reply thread
The support post ‘Add custom questions to custom event registration report’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.