Created
June 29, 2018 12:33
-
-
Save actual-saurabh/8f8f2182e67ac9bcf266b65b37d29f95 to your computer and use it in GitHub Desktop.
Enroll into a membership on completion of a specific welcome course
This file contains 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 // Do not copy this line | |
// Copy from under this line and paste into your child theme's functions.php | |
add_action( 'lifterlms_course_completed', 'llms_enroll_in_restrictive_membership', 10, 2 ); | |
function llms_completed_welcome_course( $student_id, $course_id ){ | |
/* | |
* the welcome course's id. | |
* You can get this by editing the course and getting the value of the post parameter of the screen's url | |
* https://yoursite.com/wp-admin/post.php?post=123&action=edit | |
*/ | |
$welcome_course_id = 123; | |
/* | |
* the membership's id. | |
* You can get this by editing the membership and getting the value of the post parameter of the screen's url | |
* https://yoursite.com/wp-admin/post.php?post=456&action=edit | |
*/ | |
$restrictive_membership_id = 456; | |
// prevent an inception like scenario and run the remaining code only when student completes welcome course | |
if( (int) $course_id === (int) $welcome_course_id ){ | |
return; | |
} | |
// enroll student into the welcome course | |
llms_enroll_student( $student_id, $restrictive_membership_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment