Skip to content

Instantly share code, notes, and snippets.

@New0
Last active January 25, 2018 19:55
Show Gist options
  • Save New0/91031595d4756ac70f525db1d6762658 to your computer and use it in GitHub Desktop.
Save New0/91031595d4756ac70f525db1d6762658 to your computer and use it in GitHub Desktop.
Caldera Forms Reorder CSV Columns
/**
* Apply the new columns order in Csv attached to email and CSV stored in admin
*/
add_filter( 'caldera_forms_email_csv_data', 'cf_reorder_csv_columns', 10, 2 );
add_filter( 'caldera_forms_admin_csv', 'cf_reorder_csv_columns', 10, 2 );
/**
* Reorder columns in Caldera Forms generated CSV file
*/
function cf_reorder_csv_columns( $csv_data, $form ){
//IMPORTANT change form ID ( CF5a5e8452c6f82) to match your form
//IMPORTANT the number after $csv_data match the order of current CSV columns, column A is 0, B is 1...
if( 'CF5a5e8452c6f82' === $form[ 'ID' ] ){
$csv_data = array(
$csv_data[3],
$csv_data[5],
$csv_data[6],
$csv_data[0]
);
}
return $csv_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment