Last active
July 15, 2017 21:48
-
-
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/
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 | |
/** | |
* 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 ); |
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 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