Filter uncanny-automator-pro

automator_certificate_tcpdf_dest

Filters the PDF destination for LearnDash certificates generated using the PDF certificate add-on.

add_filter( 'automator_certificate_tcpdf_dest', $callback, 10, 1 );

Description

This filter hook, `automator_certificate_tcpdf_dest`, allows developers to modify the destination file path for PDF certificates generated by Uncanny Automator for LearnDash. It fires when a certificate is being generated for an "automator" type certificate. Developers can use this to specify custom save locations or append dynamic information to the filename.


Usage

add_filter( 'automator_certificate_tcpdf_dest', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Example of how to modify the TCPDF destination for Uncanny Automator certificates.
 *
 * This filter allows you to change where the generated PDF certificate is sent.
 * By default, 'F' means save to a local file. You could change this to 'I' to
 * force download in the browser, or 'S' to get the content as a string.
 *
 * @param string $destination The current TCPDF destination.
 * @return string The modified TCPDF destination.
 */
add_filter( 'automator_certificate_tcpdf_dest', 'my_automator_custom_certificate_destination', 10, 1 );

function my_automator_custom_certificate_destination( $destination ) {
    // Let's say we want to force download for specific automator-generated certificates
    // For demonstration, we'll assume a specific trigger type is available to check.
    // In a real scenario, you might have access to more context within the filter,
    // or you might apply this logic globally.
    //
    // IMPORTANT: This is a simplified example. The actual context available to this filter
    // might be more complex or require checking other global variables or passed arguments
    // if the hook provided them. The provided source context shows 'F' is the initial value.

    // If you wanted to always force download instead of saving to file:
    // return 'I';

    // If you wanted to conditionally change it, you'd need some logic here.
    // For example, if you knew this was for a specific type of 'automator' trigger that
    // you wanted to treat differently:
    // if ( defined( 'MY_SPECIFIC_AUTOMATOR_TRIGGER_ACTIVE' ) && MY_SPECIFIC_AUTOMATOR_TRIGGER_ACTIVE ) {
    //     return 'I'; // Force download for this specific scenario
    // }

    // Otherwise, return the original destination to maintain default behavior.
    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

uncanny-automator-pro/src/integrations/learndash/helpers/learndash-pro-helpers.php:1162

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;
			default:
				$output = apply_filters( 'automator_generate_quiz_certificate_tcpdf_dest', 'I' );
				break;

		}


Scroll to Top