Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
GravityView - Modify the CSV file name
* Modify the name of the generated CSV file. Name will be sanitized using sanitize_file_name() before output.
* Requires GravityView 2.1 or newer.
* @param string $original_filename File name used when downloading a CSV. Default is "{View title}.csv"
* @param \GV\View $view Current View being rendered
add_filter( 'gravityview/output/csv/filename', function( $original_filename = '', $view ) {
// A View named "Guest List" will output "Guest-List-2018-09-27-184829.csv"
$new_filename = $original_filename . '-' . current_time( 'mysql' );
return $new_filename;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment