Support

Home Forums Event Espresso Premium Custom Ordered CSV Columns Issue

Custom Ordered CSV Columns Issue

Posted: January 29, 2018 at 10:49 am


bld_espresso

January 29, 2018 at 10:49 am

Hello,
I am running into an odd issue when using custom ordering of CSV columns from user registrations. The ordering is working fine but when a question is removed from a group that my custom CSV columns array has in it, the csv will export that column with a number in the column (I’m assuming the index of the question).

So for example if my custom columns are id, name, and height and I remove the height question, in my CSV the height column will still export and populate with 3 on all registrations.

I am using the filter FHEE__EE_Export__report_registrations__reg_csv_array and passing it an ordered array to list the columns

You can view my code in this pastebin.

So I have a couple questions. Is it possible to just set these missing columns to return nil/an empty string instead of the question index OR only export the data column IF that question actually exists as part of the registration questions?

Thank you for your time.


Tony

  • Support Staff

January 29, 2018 at 3:21 pm

Hi there,

That an interesting problem I hadn’t thought of when creating that snippet.

The number you can see if the index of the allowed_fields_in_order array, once its flipped (using array_flip()) so that fields you set are used for the keys, the numeric index becomes the value, then array_merge is using the value.

So the simplest fix is to set the value of each element in the allowed_fields_in_order array to an empty string so even if the value is used its empty.

I’ve updated my code here: https://github.com/eventespresso/ee-code-snippet-library/blob/master/admin/tw_ee_registration_report_limit_columns_shown.php#L12-L29

If you copy the highlighted section from my code and replace the code in your snippet with that (basically everything outside of creating your order array) it should fix the problem for you.


bld_espresso

January 30, 2018 at 12:10 pm

Tony,
That worked great! Thank you for your assistance.


Tony

  • Support Staff

January 30, 2018 at 2:11 pm

You’re most welcome, I’m glad that worked for you.

The support post ‘Custom Ordered CSV Columns Issue’ 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.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Tony 3 months, 3 weeks ago ago

Topic Tags

Tagged: 

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!