Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

frm_pdfs_export_file_name

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.

Use this hook to filter the PDF entry export file name.

Usage

add_filter('frm_pdfs_export_file_name', 'prepend_site_name' , 10, 2);

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

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 PDF 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 PDF 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;
}

If you need to append the field value to the PDF filename, replace line 7 with the following:

$file_name = $file_name. '-' . $fieldvalue;

Customize downloaded PDF filename to match post title

Use this code example to change all PDFs downloaded for the form to match their associated post title made from a Post action. Replace 23 with your form ID.

add_filter('frm_pdfs_export_file_name', 'use_post_title_for_pdf_filename' , 10, 2);
function use_post_title_for_pdf_filename( $file_name, $args ) {
	$target_form_id = 23; //Change 23 to the ID of the form.
	if ( $target_form_id !== (int) $args['entry']->form_id ) {
		return $file_name;
	}

	$post_id = $args['entry']->post_id;
	if ( ! $post_id ) {
		return $file_name;
	}

	$post = get_post( $post_id );
	if ( ! $post || ! $post->post_title ) {
		return $file_name;
	}

	return $post->post_title;
}
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2025 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Special offer unlocked.
    Get 55% OFF!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms