Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active July 15, 2017 21:48
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/2ada9df7a0e15ec5e45c6cf8be0ca60e to your computer and use it in GitHub Desktop.
Save Shelob9/2ada9df7a0e15ec5e45c6cf8be0ca60e to your computer and use it in GitHub Desktop.
Example code for caldera_forms_email_csv_data filter in Caldera Forms See: https://calderaforms.com/doc/caldera_forms_email_csv_data/
.<?php
/**
* Change the label of a specific field in Caldera Forms email CSV
*/
add_filter( 'caldera_forms_email_csv_data', function( $csv_data, $form ){
//IMPORTANT change form ID to match your form
if( 'cf123456' === $form[ 'ID' ] ){
$labels = wp_list_pluck( $csv_data , 'label' );
foreach ( $labels as $i => $label ){
if( 'Price' === $label ){
$label = 'Total Price';
$csv_data[ $i ] = $label;
}
}
}
return $csv_data;
}, 10, 2 );
<?php
/**
* Add an additional column to Caldera Forms email CSV
*/
add_filter( 'caldera_forms_email_csv_data', function( $csv_data, $form ){
//IMPORTANT change form ID to match your form
if( 'cf123456' === $form[ 'ID' ] ){
$csv_data[] = array(
'label' => 'Unique ID',
'data' => 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