Purpose

Customize the filename of the generated PDF. This filter allows external plugins or custom logic to dynamically adjust the filename based on specific conditions.

Usage

add_filter( "wr_pdf_template_filename", array( $this, "custom_filename" ), 10, 3 );

Parameters

  • $filename (string): The default filename of the generated PDF.
  • $payload (array): The data associated with the template request.

Use Case

This functionality is useful when:

  • You need to generate custom filenames for PDFs, such as including unique identifiers, timestamps, or user-specific information.
  • Specific templates require unique naming conventions.

Implementation Example

The following example sets a custom filename for PDFs associated with a specific identifier:

add_filter( "wr_pdf_template_filename", array( $this, "custom_filename" ), 10, 3 );
 
public function custom_filename( $filename, $payload ) {
	if ( $payload["identifier"] == "identifier" ) {
		$filename = "custom.pdf"
	}
	return $filename;
}