Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Created September 27, 2018 18:49
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 zackkatz/2eceeac0a45ab992c798286304466ef8 to your computer and use it in GitHub Desktop.
Save zackkatz/2eceeac0a45ab992c798286304466ef8 to your computer and use it in GitHub Desktop.
GravityView - Modify the CSV file name
<?php
/**
* 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