Filter Since 2.4.7 uncanny-automator-pro

learndash_certificate_params

Filters certificate tcpdf paramaters. Filters the TCPDF parameters used to generate a LearnDash certificate before it's created.

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

Description

Allows developers to modify TCPDF parameters for LearnDash certificates before they are generated. This hook fires just before the TCPDF object is instantiated, enabling fine-grained control over PDF orientation, units, and format. Modify the `$tcpdf_params` array to customize the certificate's PDF output.


Usage

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

Parameters

$tcpdf_params (array)
An array of tcpdf parameters.
$cert_id (int)
Certificate post ID.

Return Value

The filtered value.


Examples

add_filter( 'learndash_certificate_params', 'my_custom_learndash_certificate_params', 10, 2 );

/**
 * Example custom function to modify LearnDash certificate TCPDF parameters.
 * This example adds a custom font to the certificate PDF.
 *
 * @param array $tcpdf_params An array of tcpdf parameters.
 * @param int   $cert_id      Certificate post ID.
 * @return array The modified tcpdf_params array.
 */
function my_custom_learndash_certificate_params( $tcpdf_params, $cert_id ) {

	// Check if the certificate ID is for a specific certificate we want to modify.
	// Replace '123' with the actual post ID of your certificate.
	if ( 123 === $cert_id ) {

		// Add a custom font. Ensure the font file is correctly registered with TCPDF.
		// For demonstration, we'll assume 'mycustomfont' is a registered font name.
		// You would typically register your font using TCPDF's AddFont method elsewhere
		// or ensure it's available.
		$tcpdf_params['fontpath'] = WP_PLUGIN_DIR . '/my-custom-plugin/fonts/'; // Path to your custom fonts directory
		$tcpdf_params['font']     = 'mycustomfont'; // The name you registered your font with

		// You could also modify other parameters if needed:
		// $tcpdf_params['orientation'] = 'P'; // Portrait
		// $tcpdf_params['unit']        = 'mm';
		// $tcpdf_params['format']      = 'A4';
	}

	return $tcpdf_params;
}

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

* Filters certificate tcpdf paramaters.
		 *
		 * @param array $tcpdf_params An array of tcpdf parameters.
		 * @param int $cert_id Certificate post ID.
		 *
		 * @since 2.4.7
		 */
		$tcpdf_params = apply_filters( 'learndash_certificate_params', $tcpdf_params, $cert_args['cert_id'] );

		$pdf = new TCPDF(
			$tcpdf_params['orientation'],
			$tcpdf_params['unit'],
			$tcpdf_params['format'],
			$tcpdf_params['unicode'],
			$tcpdf_params['encoding'],


Scroll to Top