Email Quiz Certificates

Overview

Email Quiz Certificates* module is part of the Pro Suite of modules for the Uncanny LearnDash Toolkit. Out of the box, LearnDash supports dynamic generation of a certificate after successful completion of a quiz, but the certificate must be viewed online or downloaded to the user’s computer. This Pro module extends LearnDash functionality to attach a certificate to the email that is sent to the user upon the successful completion of a quiz. The certificate email can also be sent to site administrators, group leader(s) or any number of related users.

*This module will send out email with certificate with any quiz that has a certificate associated with it.  For sending certificates that are attached to courses, use this module instead.

Module Settings

  • Use Cron to send certificate: This setting should only be checked if you are having issues with shortcodes not outputting the correct data in the emailed certificates.  Otherwise it should be left unchecked.
  • Do not store certificates on server: This module by default stores certificates on server.  Check this option to disabled this behavior.
  • From Name/From Email: The name and email address that the certificate email will be sent from. If left blank, the LearnDash quiz email settings will be used for from name and email.
  • Send Certificate to Site Admin/Group Leader(s): Check to send a copy of the email with the certificate attached to the site admin and/or group leader(s).
  • CC Certificate To: Include anyone else you want the email CC’d to in this field.
  • Admin/Group Leader Email Subject & Admin/Group Leader Email Body: These fields control the email content for emails sent to the site admin, group leader(s) and cc recipients.  Tokens are available and listed just below the Email Body field.

 

Filters for Developers

This module provides a number of filters for developers:

Modify default save path
uo_quiz_certificate_save_path
return new path, defaults to: /uploads/user-certificates/
Modify default filename
uo_quiz_completion_certificate_filename // 
returns filename. 
Passed arguments:
$file_name //default filename
$user_id //current user id
$quiz_id //current quiz id 
$certificate_post //certificate post
self::$current_time_stamp //quiz completion time
whether to generate certificate or not
uo_generate_quiz_certificate
return true/false
Default: True
Modify HTTP url of the certificate.. mandatory if path is changed
uo_quiz_certificate_http_url
passed default http url
return new path
Modify certificate content on-the-fly
uo_generate_quiz_certificate_content
Default: certificate content
arguments passed:
$content //default certificate content
$user_id //user id 
$quiz_id //quiz id
$course_id //course id that the quiz belonged to
Usage: add user_id or quiz_id or course_id to a shortcode in the content.
Example: preg_replace( '/(\[usermeta)/', '[usermeta user_id="' . $user_id . '" ', $content );
16 replies
  1. Michael
    Michael says:

    Is there a way to remove the attachment from the certificate email? I want them to be notified, but not have the file directly sent to them.

    Reply
    • Ryan
      Ryan says:

      Can you confirm who you want to be notified? LearnDash natively supports notifying the user and admin about quiz results. If you disable our module that notification will go out. If you need Group Leaders and other users to be notified, however, our module would then be needed and it always includes the certificate. Another option may be using the LearnDash Notifications plugin instead from LearnDash, as I’m afraid our email modules always send the attachments.

      Reply
    • Ryan
      Ryan says:

      That is unfortunately not currently possible.

      The email trigger itself comes from LearnDash; emails are either sent or they’re not. Our module basically overrides that email to attach a certificate if one was earned, but whether or not the email is sent comes from LearnDash, and currently there is no option to only send notifications when quizzes are passed. We may consider overriding that for a future release, but for now, unfortunately, emails are sent regardless of passing or failing.

      Reply
  2. George Webb
    George Webb says:

    “currently there is no option to only send notifications when quizzes are passed” – Hello, is this still the case? I don’t want to send a certificate if the student hasn’t achieved the pass mark of 80%

    Reply
    • Ryan
      Ryan says:

      This behaviour is on the LearnDash side; it means an email always goes out, not that a certificate will always be attached. So if this is turned on, the email goes out in all cases, but the certificate will only be attached if the user achieves 80% or higher.

      Reply
    • Ryan
      Ryan says:

      The solution does require a code addition in your child theme and may be better handled via support ticket, but here’s a code sample to hopefully point you in the right direction:

      /**
      * @param $file_name
      * @param $user_id
      * @param $quiz_id
      * @param $certificate_post
      * @param $timestamp
      *
      * @return string
      */
      function update_quiz_certificate_filename( $file_name, $user_id, $quiz_id, $certificate_post, $timestamp ) {
      $quiz_post = get_post( $quiz_id );
      $quiz_title = $quiz_post->post_name; //sanitized title of the quiz
      $user = get_user_by( 'ID', $user_id );
      $first_name = sanitize_title( $user->first_name );
      $last_name = sanitize_title( $user->last_name );

      return "{$timestamp}-{$first_name}-{$last_name}-{$quiz_title}-{$user_id}";
      }

      add_filter( 'uo_quiz_completion_certificate_filename', 'update_quiz_certificate_filename', 20, 5 );

      Reply
  3. Ruben Marissen
    Ruben Marissen says:

    A question, I made some short codes to be included in the Certificate Builder. They show fine when an user generates a Certificate, but in the .pdf that gets sent it shows empty on those places.

    Reply
    • Ryan
      Ryan says:

      You can try the Cron option at the top of the modules settings to delay the certificate generation slightly, giving the system more time to populate data, but you may need to raise a ticket. What is likely happening is that the data needed by the shortcode isn’t available yet at the time the email is sent. If the Cron option doesn’t help, let us know what data you’re working with and how it’s populating when you open a ticket.

      Reply

Comments/Questions

Please note that this is not a support forum. If you are experiencing issues on your site, please open a support ticket instead. Site-specific support questions submitted as comments will be unanswered.

Leave a Reply