Last active
April 25, 2025 03:42
-
-
Save rafaehlers/2b95efdaa3eba58ce54a163ec974b4ad to your computer and use it in GitHub Desktop.
Change GravityExport Lite export filename
This file contains hidden or 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 // DO NOT COPY THIS LINE | |
/** | |
* Change GravityExport Lite export filename. | |
* | |
* Hook: gfexcel_renderer_filename ← all forms | |
* gfexcel_renderer_filename_{ID} ← one specific form | |
* | |
* @param string $filename The filename generated by the plugin. | |
* @param int $form_id (Since v1.6) ID of the form being exported. | |
* | |
* @return string New filename. MUST keep the .xlsx extension. | |
*/ | |
function gk_custom_excel_filename( $filename, $form_id = 0 ) { | |
// 1 ) Pick the base name you want to see on every file | |
$base = 'Custom-Filename'; // ← change this to anything | |
// 2 ) Build the date suffix in “YYYY MM DD” (e.g. 2025 04 25) | |
$date = gmdate( 'Y-m-d' ); // gmtime avoids server-TZ surprises | |
// 3 ) Return the final name | |
return sanitize_file_name( "{$base}-{$date}" ); | |
} | |
add_filter( 'gfexcel_renderer_filename', 'gk_custom_excel_filename', 10, 2 ); | |
/* | |
* Want it for just one form? Replace the last line with, e.g.: | |
* add_filter( 'gfexcel_renderer_filename_42', 'gk_custom_excel_filename', 10, 2 ); | |
* …where 42 is your form’s ID. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment