Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Controller_Certificates::download( $cert_id )

Download a Certificate.

Description Description

Generates an HTML export of the certificate from the "Download" button on the View Certificate front end & on reporting backend for admins.

Top ↑

Return Return


Top ↑

Source Source

File: includes/controllers/class.llms.controller.certificates.php

	private function download( $cert_id ) {

		$filepath = llms()->certificates()->get_export( $cert_id );
		if ( is_wp_error( $filepath ) ) {
			// @todo Need to handle errors differently on admin panel.
			return llms_add_notice( $filepath->get_error_message(), 'error' );

		header( 'Content-Description: File Transfer' );
		header( 'Content-Type: application/octet-stream' );
		header( 'Content-Disposition: attachment; filename="' . basename( $filepath ) . '"' );

		readfile( $filepath ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_readfile

		// Delete file after download.
		ignore_user_abort( true );
		wp_delete_file( $filepath );

Top ↑

Changelog Changelog

Version Description
4.3.1 Properly use an error notice to display a WP_Error.
3.18.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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