MainWp Pro Reports with Date in Filename

Hello,

i found in a other thread the snippet to change the Filename in Pro Reports. I was wondering if it is possible, to add after the new filename the creation date of the report ?

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

Thx
br

Hi Sallida,

Can you try with somthing like this:

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 ) {
      $date = date("Y/m/d");
      return 'pro-report-' . $date . '.pdf';
   }
}

Hi Bogdan,
thanks, code works:)
br

1 Like

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