Filter Since 3.2.0 uncanny-continuing-education-credits

learndash_certificate_content

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

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

Description

This filter allows modification of the final certificate content after all shortcodes and dynamic data have been processed. Developers can use this hook to add or alter HTML/text, perhaps for branding or custom late additions, before the certificate is rendered.


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

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

/**
 * Example function to modify LearnDash certificate content.
 * This function adds a custom message 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.
 */
function my_custom_learndash_certificate_content( $cert_content, $cert_id ) {
    // Check if this is a specific certificate we want to modify, or all.
    // For this example, let's assume we want to add a message to all certificates.
    // If you wanted to target a specific certificate, you'd add a condition like:
    // if ( $cert_id === 123 ) { ... }

    // Add a custom message to the end of the certificate content.
    $custom_message = '<p style="text-align: center; margin-top: 20px; font-style: italic;">Congratulations on your achievement!</p>';

    // Append the custom message to the existing content.
    $modified_cert_content = $cert_content . $custom_message;

    // Return the modified content.
    return $modified_cert_content;
}

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

*
		 * @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