Last active
August 26, 2022 08:06
-
-
Save vcat-support/d0b817a4270c302d6325d76b0b67d017 to your computer and use it in GitHub Desktop.
Example on how to change the file name of the zip archive.
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 | |
/** | |
* Plugin Name: Bulk Download for Gravity Forms - Change zip file name. | |
* Description: Example on how to change the file name of the zip archive. | |
* Author: VCAT Consulting GmbH | |
* Author URI: https://www.vcat.de | |
*/ | |
/** | |
* Filter the file name of the zip archive (without extension). | |
* | |
* @param string $filename The current zip archive file name. | |
* @param array $form The GF form array. | |
* @param array $entry_ids The entry IDs of all files being added to the archive. | |
* | |
* @return string | |
*/ | |
function my_bdfgf_download_filename( $filename, $form, $entry_ids ) { | |
// We append the current date/time to the end of the file name. | |
return $form['title'] . ' - ' . date_i18n( 'Y-m-d H:i:s' ); | |
} | |
add_filter( 'bdfgf_download_filename', 'my_bdfgf_download_filename', 10, 3 ); | |
/** | |
* Filter the file name of the zip archive (without extension) just for the form with ID 2. | |
* | |
* @param string $filename The current zip archive file name. | |
* @param array $form The GF form array. | |
* @param array $entry_ids The entry IDs of all files being added to the archive. | |
* | |
* @return string | |
*/ | |
function my_bdfgf_download_filename_form_id_2( $filename, $form, $entry_ids ) { | |
// We append the current date/time to the end of the file name. | |
return $form['id'] . ' - ' . $form['title'] . ' - ' . date_i18n( 'Y-m-d H:i:s' ); | |
} | |
add_filter( 'bdfgf_download_filename_2', 'my_bdfgf_download_filename_form_id_2', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The filter can now be used either for all forms or just for a form with a specific ID:
Applies to all forms:
Applies to a specific form. In this case, form id 2: