uo_generate_course_certificate_tcpdf_dest
Filters the destination for course certificate PDF generation using TCPDF, allowing modification of the save path.
add_filter( 'uo_generate_course_certificate_tcpdf_dest', $callback, 10, 1 );
Description
Filters the destination for generated course certificates using TCPDF. Developers can use this hook to change where the PDF certificate is saved or displayed (e.g., 'I' for inline display, 'D' for download, 'S' for string output). The default is 'F' for saving to a file.
Usage
add_filter( 'uo_generate_course_certificate_tcpdf_dest', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of using the 'uo_generate_course_certificate_tcpdf_dest' filter.
*
* This filter allows you to change the destination for the generated course certificate PDF.
* By default, 'F' means the PDF will be saved to a file on the server.
* This example demonstrates how to change it to 'D' to force a download by the user.
*
* @param mixed $destination The current destination value. 'F' by default.
* @return string The modified destination value.
*/
add_filter( 'uo_generate_course_certificate_tcpdf_dest', 'my_custom_course_certificate_destination', 10, 1 );
function my_custom_course_certificate_destination( $destination ) {
// If the current destination is 'F' (save to file), change it to 'D' (download).
// You could also add logic here to conditionally change the destination based on user roles,
// course IDs, or other factors.
if ( $destination === 'F' ) {
return 'D'; // Force download of the certificate
}
// Otherwise, return the original destination.
return $destination;
}
?>
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:814
case 'quiz':
$output = apply_filters( 'uo_generate_quiz_certificate_tcpdf_dest', 'F' );
break;
case 'group':
$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;
}