Introduction
Use this filter to change the name of the PDF file generated via the PDF Generator Add-On.
- To change the filename of PDF which users download from the server
Use the gravityflowpdf_download_file_name filter. It has the exact same parameter structure and fully supports the {workflow_pdf_download_link} merge tag. - To create a copy of the PDF file on the server
Use the gravityflowpdf_generated action hook.
Note: This filter changes the file name on the server and has been deprecated as it would cause possible issues with merge tags and PDF download links. If you were using it prior to deprecation (V1.5) we recommend two potential changes for your code:
Parameters
Parameter | Type | Definition |
---|---|---|
$file_name | String | The file name |
$entry_id | Integer | The Entry ID |
$form_id | Integer | The Form ID |
Examples
Adds a prefix to the name of the file.
add_filter( 'gravityflowpdf_file_name', 'sh_gravityflowpdf_file_name', 10, 3 );
function sh_gravityflowpdf_file_name( $file_name, $entry_id, $form_id ) {
return 'my-pdf-' . $file_name;
}
Adds a prefix of the Step ID to the name of the file for certain steps.
add_filter( 'gravityflowpdf_file_name', 'sh_filename_with_step', 10, 3 );
function sh_filename_with_step( $file_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' ) {
$file_name = 'step-' . $step->get_id() . '-' . $file_name;
}
return $file_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?