Support

Home Forums Event Espresso Premium Custom Column Header Names for CSV Export

Custom Column Header Names for CSV Export

Posted: August 21, 2018 at 9:28 pm


LarnieBee

August 21, 2018 at 9:28 pm

Hey there,

Just wondering if there is a way to export Custom Column Header Names on the CSV Export. I have managed to customise the output of the columns and the order but I would love to be able to change the header names eg: ‘Last Name[ATT_lname]’ to ‘Last name’
This is for EE4
๐Ÿ™‚


Josh

  • Support Staff

August 22, 2018 at 8:04 am

Hi,

You can add this code snippet to your custom functions file:

https://gist.github.com/joshfeck/a4d95889cf4b9bfbe8d09e9eb9d8f590

What that will do is strip away any of the [database_field] text appended to the column table headings.


LarnieBee

August 23, 2018 at 7:12 pm

Cool! thank you.

Just wondering though, is there a way to actually change those headers, like if I wanted to rename one altogether?

๐Ÿ™‚


Josh

  • Support Staff

August 24, 2018 at 7:45 am

You can use a translation function to do that. The documentation has some example code:

https://eventespresso.com/wiki/how-to-change-wording-with-poedit/#custom-function


LarnieBee

August 24, 2018 at 6:50 pm

Ah yes, I tried that as I in fact have changed some wording in other areas. Unfortunately it doesn’t work for export to CSV. The column just doesn’t export. I’m guessing it’s because it doesn’t recognize the name on export.

Thanks anyway.


Josh

  • Support Staff

August 25, 2018 at 10:37 am

I double checked, the code does work. e.g. this:

function mycustom_filter_gettext( 
    $translated, 
    $original, 
    $domain 
) {
    $strings = array(
        'Time registration occurred' => 'Registration timestamp',
        // Add some more strings here
    );
    if ( isset( $strings[$original] ) ) {
        $translations = get_translations_for_domain( $domain );
        $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
}
add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 );

Results in the “Time registration occurred” column heading getting changed to “Registration timestamp”.

https://slack-files.com/T02SY781D-FCF41RG0K-aa1fd4f57e

The support post ‘Custom Column Header Names for CSV Export’ 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