Filter Since 3.3.0 uncanny-toolkit-pro

learndash_certification_content_write_cell_args

Filters the parameters passed to the TCPDF writeHTMLCell() function. Filters the arguments for writing HTML cell content to a PDF certificate before it's rendered.

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

Description

Fires before LearnDash writes certificate content to a PDF cell. Developers can modify the arguments passed to TCPDF's `writeHTMLCell()` function, offering fine-grained control over text formatting, positioning, and other cell properties within the certificate. This hook is crucial for advanced customization of certificate output.


Usage

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

Return Value

The filtered value.


Examples

add_filter(
	'learndash_certification_content_write_cell_args',
	'my_learndash_modify_certification_cell_args',
	10,
	4
);

/**
 * Modifies the cell arguments for rendering certification content to add a custom border.
 *
 * @param array    $pdf_cell_args Array of cell arguments for TCPDF writeHTMLCell function.
 * @param array    $cert_args     Array of certificate arguments.
 * @param array    $tcpdf_params  Array of TCPDF parameters.
 * @param TCPDF   $pdf           TCPDF class instance.
 *
 * @return array Modified $pdf_cell_args with custom border.
 */
function my_learndash_modify_certification_cell_args( $pdf_cell_args, $cert_args, $tcpdf_params, $pdf ) {

	// Check if we are processing a specific certificate or a general one.
	// This is just an example; you'd adapt this based on $cert_args content.
	if ( isset( $cert_args['certificate_id'] ) && $cert_args['certificate_id'] === 123 ) {

		// Add a custom border to the cell.
		// The 'border' key in $pdf_cell_args corresponds to the 'border' parameter of writeHTMLCell.
		// You can specify it as '1' for a default border, or an array for more control
		// (e.g., array('LR' => array('color' => array(0, 0, 0), 'width' => 5))).
		// For this example, let's add a simple bottom border.
		$pdf_cell_args['border'] = array(
			'B' => array(
				'color' => array( 150, 150, 150 ), // Gray color
				'width' => 0.5,
			),
		);

		// You could also modify width, height, x, or y if needed.
		// For instance, to slightly indent the content:
		// $pdf_cell_args['x'] = $pdf_cell_args['x'] + 5;
	}

	// Always return the (potentially modified) arguments.
	return $pdf_cell_args;
}

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

* @param string $pdf_cell_args See TCPDF function writeHTMLCell() parameters
		 * @param array $cert_args Array of certificate args.
		 * @param array $tcpdf_params An array of tcpdf parameters.
		 * @param TCPDF $pdf `TCPDF` class instance.
		 *
		 * @since 3.3.0
		 */
		$pdf_cell_args = apply_filters( 'learndash_certification_content_write_cell_args', $pdf_cell_args, $cert_args, $tcpdf_params, $pdf );

		// Print post
		$pdf->writeHTMLCell(
			$pdf_cell_args['w'],
			$pdf_cell_args['h'],
			$pdf_cell_args['x'],
			$pdf_cell_args['y'],


Scroll to Top