automator_generate_quiz_certificate_tcpdf_dest
Filters the PDF destination path for Learndash quiz certificates generated by the Automator plugin.
add_filter( 'automator_generate_quiz_certificate_tcpdf_dest', $callback, 10, 1 );
Description
Filters the TCPDF output destination for generated LearnDash quiz certificates. Developers can change the destination (e.g., 'I' for inline display, 'D' for download) before the PDF is saved or outputted. This hook fires after the certificate content is generated but before the file is saved to disk.
Usage
add_filter( 'automator_generate_quiz_certificate_tcpdf_dest', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the 'automator_generate_quiz_certificate_tcpdf_dest' filter.
*
* This filter allows you to change the destination where the PDF certificate is saved.
* The default value is 'F', which means saving the file to a local path.
* You could, for instance, change it to 'S' to get the PDF as a string,
* or 'I' to send it directly to the browser as a download.
*
* @param string $destination The current destination for the TCPDF output.
* 'F' for file, 'S' for string, 'I' for inline browser output, 'D' for download.
* @return string The modified destination for the TCPDF output.
*/
add_filter(
'automator_generate_quiz_certificate_tcpdf_dest',
function( $destination ) {
// Example: Change the destination to send the PDF directly to the browser as a download.
// You might do this if you want to immediately offer the certificate to the user
// after they complete a quiz, without saving it on the server.
// Be cautious with this in automated workflows, as it might interrupt the automation.
return 'D'; // 'D' means download the file.
},
10, // Priority
1 // Accepted args
);
?>
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
uncanny-automator-pro/src/integrations/learndash/helpers/learndash-pro-helpers.php:1156
uncanny-automator-pro/src/integrations/learndash/helpers/learndash-pro-helpers.php:1165
ob_clean();
$full_path = $save_path . $file_name . '.pdf';
switch ( $certificate_type ) {
case 'quiz':
$output = apply_filters( 'automator_generate_quiz_certificate_tcpdf_dest', 'F' );
break;
case 'course':
$output = apply_filters( 'automator_generate_course_certificate_tcpdf_dest', 'F' );
break;
case 'automator':
$output = apply_filters( 'automator_certificate_tcpdf_dest', 'F' );
break;