Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Created March 8, 2017 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasparsd/9c6e2e5035b310521c49e9cdd8de42f8 to your computer and use it in GitHub Desktop.
Save kasparsd/9c6e2e5035b310521c49e9cdd8de42f8 to your computer and use it in GitHub Desktop.
Exclude default fields from the CSV export
<?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