Created
March 8, 2017 17:23
-
-
Save kasparsd/9c6e2e5035b310521c49e9cdd8de42f8 to your computer and use it in GitHub Desktop.
Exclude default fields from the CSV export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'cf7_storage_csv_columns', function( $rows ) { | |
// Specify the field names you wish to remove | |
$unset_fields = array( | |
'mail-date', | |
'mail-from', | |
'mail-to', | |
'mail-subject', | |
'mail-body', | |
'mail-attachments', | |
'mail-from-name', | |
'entry-id', | |
'entry-url', | |
'http-referer', | |
'http-user-agent', | |
'http-remote-addr', | |
'field-name', // use field-YOURFIELDNAME for all custom fields | |
); | |
foreach ( $rows as &$row ) { | |
foreach ( $unset_fields as $field_name ) { | |
if ( isset( $row[ $field_name ] ) ) { | |
unset( $row[ $field_name ] ); | |
} | |
} | |
} | |
return $rows; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment