Filter uncanny-automator-pro

learndash_pdf_author

Filters the name of the pdf author. Filters the PDF author name, allowing customization before it's added to a certificate.

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

Description

This filter allows developers to modify the PDF author's name before it's embedded in a LearnDash certificate. Use it to dynamically set the author based on certificate ID or other contextual data. This hook fires when the certificate PDF is being generated and the author's name is being set within the TCPDF instance.


Usage

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

Return Value

The filtered value.


Examples

// Example: Modify the PDF author name to include a prefix if the certificate ID is even.
add_filter( 'learndash_pdf_author', 'my_learndash_pdf_author_filter', 10, 3 );

/**
 * Filters the PDF author name for LearnDash certificates.
 *
 * Adds a "CERT-" prefix to the author name if the certificate ID is an even number.
 *
 * @param string $pdf_author_name The original PDF author name.
 * @param TCPDF $pdf             The TCPDF class instance.
 * @param int    $cert_id         The certificate post ID.
 * @return string The modified PDF author name.
 */
function my_learndash_pdf_author_filter( $pdf_author_name, $pdf, $cert_id ) {
    // Check if the certificate ID is an even number.
    if ( $cert_id % 2 === 0 ) {
        // Prepend a prefix to the author name.
        return 'CERT-' . $pdf_author_name;
    }

    // Otherwise, return the original author name.
    return $pdf_author_name;
}

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:999

/**
		 * Filters the name of the pdf author.
		 *
		 * @param string $pdf_author_name PDF author name.
		 * @param TCPDF $pdf `TCPDF` class instance.
		 * @param int $cert_id Certificate post ID.
		 */
		$pdf->SetAuthor( apply_filters( 'learndash_pdf_author', $cert_args['pdf_author_name'], $pdf, $cert_args['cert_id'] ) );

		/**
		 * Filters the title of the pdf.
		 *
		 * @param string $pdf_title PDF title.
		 * @param TCPDF $pdf `TCPDF` class instance.
		 * @param int $cert_id Certificate post ID.


Scroll to Top