Created
September 24, 2019 17:50
-
-
Save actual-saurabh/b25b0f62abbb4af846d48b68c4ad91fb to your computer and use it in GitHub Desktop.
Award a Certificate associated with a trigger and an engagement to a user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Award a certificate engagement attached to a unit (course, quiz, etc) to a user | |
* @param int $user_id The ID of the user to award the certificate to. | |
* @param int $engagement_id The post ID of the engagement | |
* @param int $trigger_id The post ID of the trigger post (course, lesson, quiz, etc) | |
*/ | |
function llms_award_certificate( $user_id, $engagement_id, $trigger_id ){ | |
// See: https://github.com/gocodebox/lifterlms/blob/master/includes/class.llms.engagements.php#L100 | |
// https://github.com/gocodebox/lifterlms/blob/master/includes/class.llms.engagements.php#L379 | |
// https://github.com/gocodebox/lifterlms/blob/master/includes/class.llms.engagements.php#L158 | |
$certificates = LLMS()->certificates(); | |
// See: https://github.com/gocodebox/lifterlms/blob/master/includes/class.llms.certificates.php#L71-L85 | |
// https://github.com/gocodebox/lifterlms/blob/master/includes/class.llms.certificate.php#L186-L238 | |
$certificates->trigger_engagement( $user_id, $engagement_id, $trigger_id ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment