Description
Use this filter to change the name of the downloadable PDF file via the merge tag.
Parameters
Parameter | Type | Definition |
---|---|---|
$name | String | The filename |
$entry_id | Integer | The Entry ID |
$form_id | Integer | The Form ID |
Examples
Add a prefix to the name of the file.
add_filter( 'gravityflowpdf_download_file_name', 'sh_gravityflowpdf_download_file_name', 10, 3 );
function sh_gravityflowpdf_download_file_name( $name, $entry_id, $form_id ) {
return 'my-pdf-' . $name;
}
Add a prefix of the Step ID to the name of the file for certain steps.
add_filter( 'gravityflowpdf_download_file_name', 'sh_downloadfilename_with_step', 10, 3 );
function sh_downloadfilename_with_step( $name, $entry_id, $form_id ) {
$api = new Gravity_Flow_API( $form_id );
$entry = GFAPI::get_entry( $entry_id );
$step = $api->get_current_step( $entry );
if( $step->get_id() == '3' ) {
$name = 'step-' . $step->get_id() . '-' . $name;
}
return $name;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?