Filter Since 3.2.0 uncanny-automator-pro

learndash_certificate_content

Filters certificate content after all processing. Filters the certificate's post content HTML/TEXT after all processing, allowing modifications before display.

add_filter( 'learndash_certificate_content', $callback, 10, 2 );

Description

Filters the final certificate content, allowing modification of the HTML/TEXT after LearnDash has processed it. Use this hook to dynamically alter certificate output based on the certificate ID and its generated content before it's displayed or saved.


Usage

add_filter( 'learndash_certificate_content', 'your_function_name', 10, 2 );

Parameters

$cert_content (string)
Certificate post content HTML/TEXT.
$cert_id (int)
Certificate post ID.

Return Value

The filtered value.


Examples

<?php
/**
 * Example: Add a custom footer message to LearnDash certificates.
 *
 * This function demonstrates how to use the 'learndash_certificate_content'
 * filter to append a custom footer to the certificate content.
 *
 * @param string $cert_content The original certificate content (HTML/TEXT).
 * @param int    $cert_id      The ID of the certificate post.
 * @return string The modified certificate content with the added footer.
 */
function my_custom_learndash_certificate_footer( $cert_content, $cert_id ) {
    // Check if the certificate ID is a specific one we want to modify (optional).
    // Replace 123 with the actual certificate ID you want to target.
    if ( $cert_id === 123 ) {
        $custom_footer = '<p style="text-align: center; font-size: 10px; color: #888;">'
                       . esc_html__( 'This certificate is a representation of achievement.', 'my-text-domain' )
                       . '</p>';
        $cert_content .= $custom_footer;
    }

    // Always return the potentially modified content.
    return $cert_content;
}
add_filter( 'learndash_certificate_content', 'my_custom_learndash_certificate_footer', 10, 2 );
?>

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

* Filters certificate content after all processing.
		 *
		 * @param string $cert_content Certificate post content HTML/TEXT.
		 * @param int $cert_id Certificate post ID.
		 *
		 * @since 3.2.0
		 */
		$cert_content = apply_filters( 'learndash_certificate_content', $cert_content, $cert_args['cert_id'] );

		/**
		 * Build the PDF Certificate using TCPDF.
		 */
		if ( ! class_exists( 'TCPDF' ) ) {
			require_once LEARNDASH_LMS_LIBRARY_DIR . '/tcpdf/config/lang/' . $cert_args['lang'] . '.php';
			require_once LEARNDASH_LMS_LIBRARY_DIR . '/tcpdf/tcpdf.php';


Scroll to Top