uo_generate_preview_certificate_tcpdf_dest
Filters the destination method used by TCPDF to generate certificate previews.
add_filter( 'uo_generate_preview_certificate_tcpdf_dest', $callback, 10, 1 );
Description
Filters the destination for TCPDF certificate output when generating a preview. Allows developers to change how the preview certificate is handled, such as forcing a download ('D') instead of inline display ('I').
Usage
add_filter( 'uo_generate_preview_certificate_tcpdf_dest', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Filter to change the output destination for preview certificates.
*
* By default, 'I' (inline display in browser) is used for previews.
* This example demonstrates how to change it to 'D' (force download).
*/
add_filter( 'uo_generate_preview_certificate_tcpdf_dest', function( $destination ) {
// Check if a specific condition is met to change the output.
// For example, if a specific query parameter is present in the URL,
// or if the user is an administrator.
if ( isset( $_GET['force_download_preview'] ) && $_GET['force_download_preview'] === 'true' ) {
return 'D'; // Force download
}
// Otherwise, return the original destination (inline display).
return $destination;
}, 10, 1 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/includes/tcpdf-certificate-code.php:818
$output = apply_filters( 'uo_generate_group_certificate_tcpdf_dest', 'F' );
break;
case 'course':
$output = apply_filters( 'uo_generate_course_certificate_tcpdf_dest', 'F' );
break;
case 'preivew':
default:
$output = apply_filters( 'uo_generate_preview_certificate_tcpdf_dest', 'I' );
break;
}
$pdf->Output( $full_path, $output ); /* F means saving on server. */
// Reset current user ID to original.