I have a problem with the export (CSV) of my clients list for a lecon.
When I export the file all work but information are separate by , and excel need ; . Who I can change this in the file php?
That function is within a plugin but you could also just ad that to your themes functions.php file or create your own Custom Functions Plugin and add the function to that.
<?php
/*
Plugin Name: Fichecod106
Description: Creation de fiche de cours pour cod106
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
//only include these 4 columns in the registration CSV output
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(
__( 'Prénom[ATT_fname]', 'event_espresso' ),
__( 'Nom[ATT_lname]', 'event_espresso' ),
__( 'Adresse' ),
__( 'npa' ),
__( 'Localite' ),
__( 'lé', 'event_espresso' ),
__( 'Date de naissance', 'event_espresso' ),
__( 'Titre - System Question', 'event_espresso' ),
__('Transaction Etat', 'event_espresso'),
__('Téléphone[ATT_phone]', 'event_espresso'),
//custom question's admin label, doesn't need to be translated. note though: if you ever change the custom question's admin label, this code will need to be adjusted
) ) );
return $filtered_csv_row;
}
function tw_ee_set_csv_delimiter( $delimiter ) {
//Change the CSV delimited/seperator to be a semi colon.
$delimiter = ';';
return $delimiter;
}
add_filter( 'FHEE__EE_CSV__fputcsv2__delimiter', 'tw_ee_set_csv_delimiter' );
/* Stop Adding Functions */
array_intersect_key() which that functions uses does not alter the order of the CSV at all. It simply looks in the array and returns the values for keys that match what you have set.
You need a different function when you want to change the order, we have an example here:
And how i can delete this row Transaction Promotions, i not need?
The promotions add-on hooks into the same hook used above and uses priority 10, to remove it you want the above function to always run AFTER the promotions add-on has added its fields, so change the priority to something like 20.
It’s possible to put color in the columb when you export the csv?
See my csv.
<?php
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(
__( 'Titre - System Question', 'event_espresso' ),
__( 'Prénom[ATT_fname]', 'event_espresso' ),
__( 'Nom[ATT_lname]', 'event_espresso' ),
__( 'Adresse' ),
__( 'npa' ),
__( 'Localite' ),
__('Téléphone[ATT_phone]', 'event_espresso'),
__( 'Date de naissance', 'event_espresso' ),
__('Transaction Etat', 'event_espresso'),
);
//Sets $filtered_csv_row to only contain the 'allowed' fields.
$filtered_csv_row = array_intersect_key(
$csv_row,
array_flip( $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(array_flip($allowed_fields_in_order), $filtered_csv_row );
return $filtered_csv_row;
}
function tw_ee_set_csv_delimiter( $delimiter ) {
//Change the CSV delimited/seperator to be a semi colon.
$delimiter = ';';
return $delimiter;
}
add_filter( 'FHEE__EE_CSV__fputcsv2__delimiter', 'tw_ee_set_csv_delimiter' );
/* Stop Adding Functions */
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'tw_ee_espresso_reg_report_filter_columns_ordered', 20, 2);
I don’t think that will work to translate the columns name in the code. I remember that it needs the original text strings in the filter function in order to return the correct values.
To your question about doing a CSV in UTF-8, there’s some ideas in this stack exchange thread:
The support post ‘File CSV’ 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.