Skip to content

Instantly share code, notes, and snippets.

@actual-saurabh
Last active September 27, 2018 04:00
Show Gist options
  • Save actual-saurabh/2aee7bdce054ac9cb130dd318e971398 to your computer and use it in GitHub Desktop.
Save actual-saurabh/2aee7bdce054ac9cb130dd318e971398 to your computer and use it in GitHub Desktop.
Simple Micro Example - Welcome Course for Members
{
"name": "llms/welcome-course-membership",
"title": "Welcome Course Membership",
"version": "1.0.0",
"description": "Automatically enroll new members of a membership into a welcome course.",
"homepage": "https://lifterlms.com",
"author": "saurabhshukla",
"tags": [ "onboarding", "membership", "course" ],
}
<?php
/*
* Based on https://gist.github.com/actual-saurabh/3ce88c1b1465224eeab16e884d5916ec
* and a lot of dummy data for package.json
*/
defined( 'ABSPATH' ) || exit;
function_exists( 'llms_completed_welcome_course' ) && exit;
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