Last active
July 15, 2017 21:59
-
-
Save Shelob9/45c98f6136bd82fc27a24b0043aa6972 to your computer and use it in GitHub Desktop.
Example code for caldera_forms_admin_csv filter See: https://calderaforms.com/doc/caldera_forms_admin_csv/
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 extra column to Caldera Forms admin CSV export | |
* | |
* In this example, a unique ID column. | |
*/ | |
add_filter( 'caldera_forms_admin_csv', function( $csv_data, $form ){ | |
//IMPORTANT change form ID to match your form | |
if( 'cf123456' === $form[ 'ID' ] ){ | |
//Add a header for new column | |
$csv_data[ 'headers' ][ 'unique_id' ] = 'Unique ID'; | |
//Add a value for each row for this new column | |
//note that "unique_id" index matches in data and headers - you can call it whatever you want, just be consistent | |
foreach ( $csv_data[ 'data' ] as $i => $row ) { | |
$row[ 'unique_id' ] = uniqid( 'prefix' ); | |
} | |
} | |
return $csv_data; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment