Support

Home Forums Event Espresso Premium Limit columns csv EE4

Limit columns csv EE4

Posted: October 2, 2016 at 4:04 am

Viewing 9 reply threads


msegura

October 2, 2016 at 4:04 am

Hi, I need to limit the columns generated by exporting the CSV file an event. I have reviewed the forums but have not found a solution that works.

My programming skills are somewhat limited.

My version is EE4.

Excuse my English.

Greetings.
Manuel.


Tony

  • Support Staff

October 4, 2016 at 3:33 am

Hi Manuel,

We have a filter that allows you to set which fields are allowed within the CSV here:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/admin/registration_report_limit_columns_shown.php

You can add that to a Custom Functions Plugin on your site to do what you need.

The list of column names are what will be allowed through to the CSV, if you loow at the top of the CSV that you have currently you will find the column names, add the ones you want to include to the above function.


msegura

October 8, 2016 at 6:13 am

OK, thanks for the reply.

regards


msegura

October 9, 2016 at 10:29 am

Hi, I have completed the steps and when I generate the CSV file with the list of records creates the 4 columns but the data appears empty (no name, email …). As I can fix to fill the fields with the data of registered Users are recommended?

Greetings.


Lorenzo Orlando Caum

  • Support Staff

October 9, 2016 at 5:37 pm

Hello,

Could you upload your version of the FHEE__EE_Export__report_registrations__reg_csv_array (https://github.com/eventespresso/ee-code-snippet-library/blob/master/admin/registration_report_limit_columns_shown.php) to something like pastebin or GitHub gist and share here so we can share feedback?


Lorenzo


msegura

October 18, 2016 at 12:11 am

Hello, I uploaded the code I used to see where the error may be.

http://pastebin.com/g9RkXbfQ

Thank you.


Josh

  • Support Staff

October 18, 2016 at 9:53 am

Hi Manuel,

The reason it’s not working for you is because the field names were translated. The translation functions will take care of translating the strings before they’re sent to the CSV. So basically where you have this:

__( 'Nombre [ATT_fname]', 'event_espresso' ),
__( 'Apellidos [ATT_lname]', 'event_espresso' ),
__( 'Email [ATT_email]', 'event_espresso' ),

You’ll need to change it to be this:

__( 'First Name[ATT_fname]', 'event_espresso' ),
__( 'Last Name[ATT_lname]', 'event_espresso' ),
__( 'Email Address[ATT_email]', 'event_espresso' ),


msegura

October 22, 2016 at 10:38 am

Hi, I modified the code to generate the CSV but the fields are not filled as it does with the original code. I put a sample image.

Limit columns CSV


Tony

  • Support Staff

October 24, 2016 at 6:28 am

Hi there,

Using the translated strings within the function works fine however your strings MUST match the CSV output fields exactly (yours did not). You also don’t need to run translated strings through the translation function again when doing that.

The problem with the current setup is the translations don’t match the values within the CSV array, so these fields:


__( 'First Name[ATT_fname]', 'event_espresso' ),
__( 'Last Name[ATT_lname]', 'event_espresso' ),
__( 'Email Address[ATT_email]', 'event_espresso' ),

Don’t match any of the fields available within the CSV array because they include the DB field name within the translation. The above needs to be changed to:


__( 'First Name', 'event_espresso' ) . '[ATT_fname]' ,
__( 'Last Name', 'event_espresso' ) . '[ATT_lname]',
__( 'Email Address', 'event_espresso' ) . '[ATT_email]' ,

Because EE is translating the field name, then appending the DB field to the translation, but the example function is translating the field name including the DB field, which will never match anything. So we need to translate the field name, then add the DB field name to the end so that the full field name matches what is in the array.

Make sense?

The other option you have is to skip the translation within the function and just add the full field names you want to include in the CSV. So you look within the CSV, find the field name and add that to the function directly.

For example, here is a CSV I generated using the above code – http://take.ms/vpEeP

So the three fields I want are Apellido(s)[ATT_lname], Nombre de pila[ATT_fname] & Dirección de correo electrónico[ATT_email].

So lets use those directly within the function:

$allowed_fields_in_order = array(
	'Apellido(s)[ATT_lname]',
	'Nombre de pila[ATT_fname]',
	'Dirección de correo electrónico[ATT_email]',
);

As mentioned you don’t need to run those fields through the translate function __() again because you have translated them yourself.

That then exports the fields in the exact same way as above with the fixed snippet.


Tony

  • Support Staff

October 24, 2016 at 6:33 am

Also the reason this:


__( 'Nombre [ATT_fname]', 'event_espresso' ),
__( 'Apellidos [ATT_lname]', 'event_espresso' ),
__( 'Email [ATT_email]', 'event_espresso' ),

did not work is because the strings don’t match the CSV titles – http://take.ms/RRcdD

The strings you have set do not match the strings in the CSV, there is a space before the DB Field name and your using different text than your fields are.

For those 3 fields, this would have worked:


__( 'Nombre de pila[ATT_fname]', 'event_espresso' ),
__( 'Apellido(s)[ATT_lname]', 'event_espresso' ),
__( 'Dirección de Email[ATT_email]', 'event_espresso' ),

However please read my above reply as it explains further.

Viewing 9 reply threads

The support post ‘Limit columns csv EE4’ 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.

Event Espresso