llms_get_certificate_content( integer $id )

Retrieve the content of a certificate.

Description Description

This allows utilizing the LLMS_User_Certificate class with an llms_certificate post type to render a preview of the certificate template. The saved post_content will be merged (using the current user’s information).

This function is intended for use on the certificate’s front-end display template. In order to retrieve the raw content use LLMS_User_Certificate->get( 'content' ) or WP_Post->post_content.

Top ↑

Parameters Parameters


(integer) (Required) WP Post ID of the cert (optional if used within a loop).

Top ↑

Return Return


Top ↑

Source Source

File: includes/functions/llms.functions.certificate.php

function llms_get_certificate_content( $id = 0 ) {

	$content = '';

	$certificate = llms_get_certificate( $id, true );
	if ( $certificate ) {

		// If `$id` was empty to use the global, ensure an id is available in filter on the return.
		$id = $certificate->get( 'id' );

		// Get raw content because we filter it again below.
		$content = $certificate->get( 'content', true );

	/** WordPress core filter documented at {@link https://developer.wordpress.org/reference/hooks/the_content/}. */
	$content = apply_filters( 'the_content', $content );

	// Get merged content for templates.
	if ( 'llms_certificate' === get_post_type( $id ) ) {
		$content = $certificate->merge_content( $content );

	 * Filter the `post_content` of a certificate or certificate template.
	 * @since Unknown
	 * @since 6.0.0 Added the `$certificate` parameter.
	 * @param string                     $content     The certificate content.
	 * @param int                        $id          The ID of the certificate.
	 * @param bool|LLMS_User_Certificate $certificate Certificate object or `false` if the post couldn't be found.
	return apply_filters( 'lifterlms_certificate_content', $content, $id, $certificate );


Top ↑

Changelog Changelog

Version Description
6.4.0 Fixed issue with merge codes in reusable blocks by merging *after* filtering the post content.
6.0.0 Use llms_get_certificate() and LLMS_User_Certificate methods. If this function is used out of the intended certificate context this will now return an empty string, whereas previously it returned the content of the post.
3.18.0 Unknown.
2.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.