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