Support

Home Forums Event Espresso Premium Remove database tags from the CSV report header

Remove database tags from the CSV report header

Posted: June 26, 2021 at 11:30 pm


Mark

June 26, 2021 at 11:30 pm

Hi,
I want to remove the database tags from the CSV report header titles. I want to make Transaction ID[TXN_ID] to the Transaction ID.
I have read some solutions on the support forum and try to apply them but none of them is working for me.
I have us this solution https://gist.github.com/joshfeck/a4d95889cf4b9bfbe8d09e9eb9d8f590
But it is not able to delete the [TXN_ID] of the Transaction ID[TXN_ID] header title.
I have also read the translation solution https://eventespresso.com/wiki/how-to-change-wording-with-poedit/#custom-function but this solution is not able to translate the Transaction ID[TXN_ID] to Transaction ID. After analyzing the code I saw that when I used to translate the Transaction ID string it translate it perfectly but when I used this string Transaction ID[TXN_ID] to translate the translator missed that as I think the database tags are concatenated after the filter application maybe that is why the translation function is unable to get that string Transaction ID[TXN_ID].
So what is the solution now?


Tony

  • Support Staff

June 28, 2021 at 6:33 am

Hi Mark,

Event Espresso hasn’t included those DB fields in the CSV headers since version 4.9.69.p with the exception of when you have code hooking into FHEE__EE_Export__report_registrations__reg_csv_array as that code may well be expecting those column names as is.

So, starting from the beginning, do you have any custom code hooking into FHEE__EE_Export__report_registrations__reg_csv_array?


Mark

June 28, 2021 at 9:37 am

Hi Tony,

So, starting from the beginning, do you have any custom code hooking into FHEE__EE_Export__report_registrations__reg_csv_array?

No, I dont have any custom hook into FHEE__EE_Export__report_registrations__reg_csv_array.


Tony

  • Support Staff

June 28, 2021 at 9:44 am

Ok, so I assume you are using the latest version of EE4?

When you click on the export button does it take you to another page with a progress bar and then the file downloads?

Or does the file just instantly download when you click?


Mark

June 29, 2021 at 3:24 am

Hi,

When you click on the export button does it take you to another page with a progress bar and then the file downloads?

This is my scenario.


Tony

  • Support Staff

June 29, 2021 at 6:22 am

Ok, so I assume you are using the latest version of EE4?


Mark

July 1, 2021 at 2:08 am

My EE version is 4.10.10.p.


Tony

  • Support Staff

July 2, 2021 at 3:44 am

Ok, so that version definitely wouldn’t add the columns by default.

The ‘progress bar’ page I mentioned above means you are using the batch system, again meaning the DB column wouldn’t be added by default.

The only time those values would be added with the above is if you are hooking into FHEE__EE_Export__report_registrations__reg_csv_array to change something within the CSV. To explain a little that filter is our ‘legacy’ filter, it was included in the original CSV export system which did include the DB file names. So when we changed the system to stop including those DB fields we added a check to see if the above filter was in use and make sure the fields are added again to prevent any custom code breaking.

Or, the DB field names can be explicitly set to load using FHEE__EEH_Export__get_column_name_for_field__add_field_name.

You’ve said you arent’ hooking into the above, but there must be some custom code somewhere as we don’t add those fields into the CSV anymore. If you test this with only Event Espresso running and a default theme, do the files no longer show?


Mark

July 7, 2021 at 9:51 am

Hi Tony,
As I mentioned to you earlier I am not using any hook related to CSV anywhere in my website files.
Now when I am exporting registrations the progress bar isn’t appearing but the result is the same (DB tags are still there).
What should I do now?


Tony

  • Support Staff

July 7, 2021 at 10:57 am

As I mentioned to you earlier I am not using any hook related to CSV anywhere in my website files.

Yes, I gathered, however as mentioned, EE does not inject those fields unless you are using those hooks or you’re using the old CSV export (without the progress bar).

If you aren’t hooking into those features and your using the latest version then it doesn’t make any sense that you have those fields.

Now when I am exporting registrations the progress bar isn’t appearing but the result is the same (DB tags are still there).

Wait…. so you don’t have the progress bar? Did the progress bar appear previously?

Are you defining EE_USE_OLD_CSV_REPORT_CLASS in your wp-config.php file at all?


Mark

July 8, 2021 at 4:46 am

Sorry Tony for the misguidance actually we have a team of developers after discussion I got to know that we are using this define(‘EE_USE_OLD_CSV_REPORT_CLASS’, true); in our config.php
The reason being is we want the CSV-generated file name as same as it was in EE3.
So now you can assist me with that.
We want a CSV file with the same file name format(EE3 format) and without DB tags in the columns headers.
Again apologies and thanks.


Tony

  • Support Staff

July 8, 2021 at 12:23 pm

Sorry Tony for the misguidance actually we have a team of developers after discussion I got to know that we are using this define(‘EE_USE_OLD_CSV_REPORT_CLASS’, true); in our config.php

Ok, so that means you don’t get a progress bar and the file instantly downloads as you are using the old export system…. which explains why you have the DB field names.

The reason being is we want the CSV-generated file name as same as it was in EE3.

May I ask why you need the old CSV system to do that?

The new system has a filter for the filename so you can change it to whatever you need:

FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename

We want a CSV file with the same file name format(EE3 format) and without DB tags in the columns headers.

Have one of you developers first remove define(‘EE_USE_OLD_CSV_REPORT_CLASS’, true); from your wp-config.php file so you use the new system.

Then run a registration report and confirm that you first see a progress bar and that the CSV headers no longer include the DB field names.

After that, have one of those developers hook into the filename using the above and set it to be whatever you need to use.


Mark

July 9, 2021 at 4:50 am

Hi Tony,
After commenting out that code in config.php I got rid of the DB tags in the header but the filename for the CSV file is now again not contain the event name from which the file has been generated.
I need the alternative to this solution
https://eventespresso.com/topic/filename-of-export-not-giving-event-name/
Thanks.


Tony

  • Support Staff

July 9, 2021 at 8:09 am

You can use the filter I mentioned above:

FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename

With that, you can change the filename to whatever you prefer.

Including the event slug in the filename is possible if the report is for a specific event (Event Espresso -> Events -> {hover over event} -> Registrations), if it’s not then EE won’t know which event the report is for.

Just check the request to see if EVT_ID is set, if so, grab the event and include the slug in the filename you return.


Mark

July 10, 2021 at 2:32 am

Just check the request to see if EVT_ID is set, if so, grab the event and include the slug in the filename you return.

Could you please provide lines of codes to do the trick?

Thanks.


Mark

July 10, 2021 at 2:49 am

I have been using this code to make file name according to eventID


function change_event_csv_filename(){
    if(isset($_REQUEST['EVT_ID'])){
       return $_REQUEST['EVT_ID'];
    }
}
add_filter('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename','change_event_csv_filename',10,2);

When I click on generate CSV button it leads to the progress bar and then leads to 500 Internal Server error.


Tony

  • Support Staff

July 12, 2021 at 8:18 am

Yeah, that code will break as your returning nothing but an Event ID also if no EVT_ID is set on the request you return nothing at all (which breaks the filter).

You’ll need something like this:

https://gist.github.com/Pebblo/9053b0c939f039e3d97dd1de558fd18d

Note that generally, we don’t provide support for customizations/custom code (such as the above) although I’m more than happy to help point you in the right direction.

The support post ‘Remove database tags from the CSV report header’ 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