Site Overlay

Change the PDF certificate filename in LearnDash

The beauty of WordPress and open source is that virtually anything is customizable.

And premium plugins like LearnDash are not an exception to the rule.

In LearnDash, you can create certificates to reward your students after completing a quiz or finishing a course.

These certificates are generated as a PDF file on the fly. After earning the certificate, you can download the PDF file.

By default, LearnDash generates a file with the username, course name, certificate name and the website name.

Let’s say you are not interested in presenting this name format to your users, and you want something different instead.

For example, make the certificate name a combination of the website name, course and user ID.

You can do that with the following filter: learndash_certificate_builder_pdf_name

The filter admits three parameters, which we will use, filename, certificate ID, and course ID.

Then, you can use it as follows:

add_filter('learndash_certificate_builder_pdf_name', 'obi_custom_certificate_name', 10 , 3);

function obi_custom_certificate_name(){
     
     $course = get_post( $course_id ); // Instantiate the 'course' post object.
     $user   = wp_get_current_user(); // Instantiate the user object.
     $websiteName = get_bloginfo( 'name' ); // Retrieve the website name.

     $filename = $websiteName . ' - ' . $course->post_title . ' - ' . $user->ID . '.pdf'; // Build the filename structure.

     return $filename; // Always return the filename.
}

Add the code to your theme’s functions.php file, or create a custom plugin for it.

2 thoughts on “Change the PDF certificate filename in LearnDash

Leave a Reply

Your email address will not be published. Required fields are marked *