Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.