Last active
May 29, 2020 08:17
-
-
Save New0/69390162c9c745846e346814c25259fc to your computer and use it in GitHub Desktop.
Add the entry ID on CSV Entries export
This file contains hidden or 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 | |
// Based on https://calderaforms.com/doc/caldera_forms_admin_csv/ | |
add_filter( 'caldera_forms_admin_csv', function( $csv_data, $form ){ | |
//IMPORTANT change form ID to match your form | |
if( 'CF5eb5616ea264f' === $form[ 'ID' ] ){ | |
//Add a header for new column | |
$csv_data[ 'headers' ] = ['entry_id' => 'Entry ID'] + $csv_data[ 'headers' ]; | |
//Add a value for each row for this new column | |
//Use the index of array whicj corresponds to Entry ID | |
foreach ( $csv_data[ 'data' ] as $i => $row ) { | |
//Add the column in data | |
$row = ['entry_id' => strval($i)] + $row; | |
$csv_data[ 'data' ][$i] = $row; | |
} | |
} | |
return $csv_data; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment