Filter
uncanny-automator-pro
learndash_tcpdf_legacy_ld322
Filters the arguments used for generating older LearnDash 3.2.2 certificate PDF documents.
add_filter( 'learndash_tcpdf_legacy_ld322', $callback, 10, 1 );
Description
This filter hook controls the legacy LearnDash 3.2.2 TCPDF compatibility. Developers can use it to conditionally disable this older PDF generation method by returning `false`. This is primarily for internal use and advanced troubleshooting.
Usage
add_filter( 'learndash_tcpdf_legacy_ld322', 'your_function_name', 10, 1 );
Parameters
-
$cert_args(mixed) - This parameter determines whether to enable legacy LearnDash 3.2.2 PDF generation functions.
Return Value
The filtered value.
Examples
/**
* Example of how to use the learndash_tcpdf_legacy_ld322 filter.
*
* This filter allows you to conditionally enable or disable a legacy
* PDF generation method for LearnDash certificates based on certain criteria.
* For instance, you might want to disable it for older certificates
* or for specific user roles.
*/
add_filter( 'learndash_tcpdf_legacy_ld322', 'my_learndash_disable_legacy_tcpdf', 10, 2 );
/**
* Custom function to conditionally disable the legacy LD322 TCPDF method.
*
* @param bool $use_legacy_ld322 The current value of the legacy flag (default is true).
* @param array $cert_args An array of arguments related to the certificate generation.
* @return bool Returns false to disable the legacy method, true to keep it enabled.
*/
function my_learndash_disable_legacy_tcpdf( $use_legacy_ld322, $cert_args ) {
// Example: Disable the legacy method if the certificate post ID is '123'.
if ( isset( $cert_args['cert_post']->ID ) && $cert_args['cert_post']->ID === 123 ) {
return false; // Disable legacy method
}
// Example: Disable the legacy method if a specific query parameter is set.
if ( isset( $_GET['disable_legacy_pdf'] ) && $_GET['disable_pdf'] === 'yes' ) {
return false; // Disable legacy method
}
// Otherwise, keep the default behavior.
return $use_legacy_ld322;
}
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:811
$footer_enable = $_GET['footer'];
}
/**
* Start Cert post content processing.
*/
if ( ! defined( 'LEARNDASH_TCPDF_LEGACY_LD322' ) ) {
$use_LD322_define = apply_filters( 'learndash_tcpdf_legacy_ld322', true, $cert_args );
define( 'LEARNDASH_TCPDF_LEGACY_LD322', $use_LD322_define );
}
$cert_content = ! empty( $body ) ? html_entity_decode( $body ) : $cert_args['cert_post']->post_content;
// Delete shortcode for POST2PDF Converter
$cert_content = preg_replace( '|[pdf[^]]*?].*?[/pdf]|i', '', $cert_content );