Support

Home Forums Event Espresso Premium Customizing CSV output

Customizing CSV output

Posted: October 31, 2019 at 5:00 am

Viewing 6 reply threads


vrwaadmin

October 31, 2019 at 5:00 am

Hi there. I saw a few posts but some screenshots were missing, so I’m not sure how to omit fields included with the CSV and rearrange the columns as requested by the client.


Josh

  • Support Staff

October 31, 2019 at 7:18 am

Hi,

Customizing the CSV report involves adding a filter function into a small plugin. We have some example code that shows how to specify the fields to include and have them in the order specified columns. You’ll find that example here:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/admin/registration-reports/core/tw_ee_registration_report_limit_columns_shown.php

You can add the modify the above into a functions plugin. This guide shows how to add a functions plugin to your site


vrwaadmin

November 4, 2019 at 5:30 am

Thanks Josh. This is very helpful. I have been able to edit the CSV but am not able to get all the fields to come over. Is there a list of fields somewhere I can reference? I am able to get some but not many. Can I also bring over details like venue details?


Tony

  • Support Staff

November 4, 2019 at 5:45 am

Hi there,

If you remove you function and export a CSV, the column names used as the fields available on the CSV by default, you need to set that exactly as they appear in the column name for them to filter correctly in your code.

Or you can output $csv_row to the page and view what is set in that and pull the details directly.

My preferring method of doing that is to use Kint and then on say line 10 of that function use d($csv_row);

$registration_db_row also contains more details, it is all of the details from the DB for that registration row which you can also use if needed.

Can I also bring over details like venue details?

Yes, you can bring over whatever details you prefer, but you’ll need to get comfortable using our models:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

You would then just add the values to the $filtered_csv_row array just before line 34 where it is returned.


vrwaadmin

November 5, 2019 at 11:38 am

Thanks Tony! I checked and fixed the fields that weren’t appearing and they are now working. Much appreciated.

I’m a little out of my lane with the coding that looks to be required for the G-Model-System. Is there a step-by-step maybe that shows how and where to put the code and then how to call that code (if I’m wording it right) from the customizations.php plugin so that the fields are pulled over and added to the CSV?

And/or…
Is it possible to use Advanced Custom Fields to have fields on the Event page so the Event creator can enter info when they create the class and then have that data pulled over to the CSV?


vrwaadmin

November 5, 2019 at 2:15 pm

Hi again. Poking around, I saw some code from Josh here: https://gist.github.com/joshfeck/fe12aa10c1e8deef04607189b69636d3

That adds my Venue! 🙂

Is it possible to use that code to pull over other data? I have:
Course Proctor, Course ID, TCH, Water Credit, Wastewater Credit
(these are the fields I was thinking I could use ACF Pro to pull over without having to ask the questions on the registration)


Tony

  • Support Staff

November 6, 2019 at 7:53 am

I’m a little out of my lane with the coding that looks to be required for the G-Model-System. Is there a step-by-step maybe that shows how and where to put the code and then how to call that code (if I’m wording it right) from the customizations.php plugin so that the fields are pulled over and added to the CSV?

Not really as it’s expected whoever would be using the models would be familiar with PHP, I can help give you some pointers though.

With Josh’s function, inside the condition HERE, $event is an EE_Event object which means you can use it to pull any details related to the event using our models (it’s not scary, honest).

ACF basically uses normal WP custom fields on the Event and you can pull the value using various methods.

So I assume you’ve set those values on the event itself?

If so you can do something something like:

$reg_csv_array['{Column header}'] = $event->get_post_meta('{meta-key}', true);

Within that condition above.

That will use the EE_Event object to pull a custom field with whatever key you give it and add it to the array under whatever column header you set.

That help?

Viewing 6 reply threads

The support post ‘Customizing CSV output’ 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