I may be a total newbie on this one,
but i find a previous topic witht the following custom code
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’;
}
}
But it just remove the file name by ‘new-file-name.pdf’ How can we make it so it include the website ide + the date for exemple ?
bogdan
(Bogdan Rapaić)
October 6, 2021, 5:20pm
2
Hi @heavestudio ,
Can you tell me what is the exact format that you want to use?
Sure, would be nice to have
website name - date
bogdan
(Bogdan Rapaić)
October 11, 2021, 12:00pm
4
You can try with this:
add_filter( ‘mainwp_pro_reports_pdf_filename’, ‘mycustom_mainwp_pro_reports_pdf_filename’, 10, 3 );
function mycustom_mainwp_pro_reports_pdf_filename( $filename, $report, $site_id ) {
global $mainWPProReportsExtensionActivator;
$website = apply_filters( 'mainwp_getsites', $mainWPProReportsExtensionActivator->get_child_file(), $mainWPProReportsExtensionActivator->get_child_key(), $site_id );
if ( $website && is_array( $website ) ) {
$website = current( $website );
return $website['name'] . '-' . date( 'Y-m-d', $report->date_from ) . '-' . date( 'Y-m-d', $report->date_to ) . '.pdf';
}
return $filename;
}
1 Like
bogdan:
add_filter( ‘mainwp_pro_reports_pdf_filename’, ‘mycustom_mainwp_pro_reports_pdf_filename’, 10, 3 );
function mycustom_mainwp_pro_reports_pdf_filename( $filename, $report, $site_id ) {
global $mainWPProReportsExtensionActivator;
$website = apply_filters( 'mainwp_getsites', $mainWPProReportsExtensionActivator->get_child_file(), $mainWPProReportsExtensionActivator->get_child_key(), $site_id );
if ( $website && is_array( $website ) ) {
$website = current( $website );
return $website['name'] . '-' . date( 'Y-m-d', $report->date_from ) . '-' . date( 'Y-m-d', $report->date_to ) . '.pdf';
}
return $filename;
}
Thanks @Bogdan , but nothing happen
bogdan
(Bogdan Rapaić)
October 15, 2021, 11:34am
6
Can you please confirm that you have this snippet saved to the PHP section of the Custom Dashboard extension? I have seen in some cases that users save it to the CSS section by accident.
I confirm i pasted it in php section
bogdan
(Bogdan Rapaić)
October 19, 2021, 2:44pm
8
Would you mind opening a private Help Desk ticket so we can collect some additional information & investigate further?
system
(system)
Closed
November 18, 2021, 2:44pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.