MainWP Community

Change the default .pdf name on a pro report

Hello community,

I have managed to create some really cool reports to send to my clients, but I would like to know if I can change the default name of the .pdf attachment from pro-report-2020-12-15-6-7 (or whatever it happens to be at the time) to something a little more personalized, like monthly maintenance report, etc.

Thank you!

Hi Ben,

thanks for reaching out.

Yes, it’s possible to customize report filenames by using the maiwnp_pro_reports_pdf_filename filter. Here is an example:

add_filter( 'mainwp_pro_reports_pdf_filename', 'mycustom_mainwp_pro_reports_pdf_filename', 10, 3 );
if ( !function_exists( 'mycustom_mainwp_pro_reports_pdf_filename' ) ) {
  function mycustom_mainwp_pro_reports_pdf_filename( $filename, $report, $site_id ) {	
	 return 'new-file-name.pdf';
  }
}

Thanks Bogdan, that’s very cool. Last question on this topic - In which file do I modify the code?

Hi Ben, you are welcome.

You don’t have to modify the code in source files.

Basically, the best thing to do is the following:

  1. Install the MainWP Custom Dashboard Extension
  2. Go to the PHP section of this extension
  3. Paste the code in there
  4. Save Settings

However, if you prefer, you can always add this code to the functins.php file of the active theme on your Dashboard site.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.