Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active July 15, 2017 21:59
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 Shelob9/45c98f6136bd82fc27a24b0043aa6972 to your computer and use it in GitHub Desktop.
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/
<?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