Last active
July 10, 2018 14:56
-
-
Save actual-saurabh/4003eaa5e9e8d70fe13b165bc7871f87 to your computer and use it in GitHub Desktop.
Addon Course Enrollment
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( 'llms_user_enrolled_in_course', 'llms_enroll_in_addon_course', 10, 2 ); | |
function llms_enroll_in_addon_course( $student_id, $course_id ){ | |
/* | |
* the main 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 | |
*/ | |
$main_course_id = 123; | |
// bail if this wasn't an enrollment in the main course | |
if( (int) $course_id !== (int) $main_course_id ){ | |
return; | |
} | |
/* | |
* the addon 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 | |
*/ | |
$addon_course_id = 456; | |
// enroll student into the addon course | |
llms_enroll_student( $student_id, $addon_course_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment