Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
Use this hook to filter the PDF entry export file name.
Formidable Forms is the best WordPress Form Builder plugin. Get it for free!
Usage
add_filter('frm_pdfs_export_file_name', 'prepend_site_name' , 10, 2);
Parameters
- $file_name (string): The file name.
- $args (array): This contains shortcode attributes and the following values.
- entry (object): The entry object.
- form (object): The form object. This doesn't always exist.
- form_name (string): The name of form. This doesn't always exist.
Examples
Prepend site name to filename
add_filter('frm_pdfs_export_file_name', 'prepend_site_name' , 10, 2);
function prepend_site_name( $file_name, $args ) {
$file_name = sanitize_title( get_bloginfo( 'name' ) ) . '-' . $file_name;
return $file_name;
}
Prepend field value to filename
Use this code example to prepend the generated PDF file name with a value from the entry. (i.e. name of the user that created the entry)
add_filter('frm_pdfs_export_file_name', 'prepend_field_value' , 10, 2);
function prepend_field_value( $file_name, $args ) {
$entry_id=$args['entry']->id;
$fieldvalue=FrmProEntriesController::get_field_value_shortcode(array('field_id' => 2, 'entry' => $entry_id)); //change 2 to the ID of the field where the unique value is stored in your form
$file_name = $fieldvalue. '-' . $file_name;
return $file_name;
}