Adding Custom Course Statuses in WPLMS

From version 1.8.4, course statuses are stored in a custom user meta field called :course_status123 where 123 is the course id of the respective course.

The course statuses follows :
STATUS : 1 : START COURSE
STATUS : 2 : CONTINUE COURSE
STATUS : 3 : FINISH COURSE : COURSE UNDER EVALUATION
STATUS : 4 : COURSE EVALUATED

Above 1,2,3,4 are reserved status values for the theme.

The theme also has the flexibility to allow for unlimited course statuses. Course statuses can be used in a course for various custom functionality.

Check below example on how to user Custom Course Statuses in WPLMS :

Let us add a new course status when user completes a course 50%, we’ll use this Course status to display the take course button text as Half way through

1. Adding function on hook : badgeos_wplms_unit_complete

Add this code in WPLMS Customizer -> customizer_class.php
in __construct function

add_filter(‘badgeos_wplms_unit_complete’,array($th is,’custom _course_status’),10,3);

In Class :

PHP Code:

function custom _course_status($unit_id,$progress,$course_id){
$user_id = get_current_user_id();
if($progress > 0.5){
$status = 5; // New status
bp_course_update_user_course_status($user_id,$course_id,$status);
}
return $unit_id;
}

2. Displaying new information in Credits :

in __construct function
add_filter(‘wplms_course_credits’,array($this,’cus tom_wplms_course_credits’),10,2);

In class

PHP Code:

function custom_wplms_course_credits($html,$course_id){
$user_id = get_current_user_id();
$status = bp_course_get_user_course_status($user_id,$course_id);
if($status==5){
$html = '<strong>Half Way through</strong>';
}
return $html;
}

3. Display new label in the button :

in __construct function
add_filter(‘wplms_default_course_button’,array($th is,’custom_wplms_default_course_button’),10,3);

​In class

PHP Code:
function custom_wplms_default_course_button($html,$user_id,$course_id){
$user_id = get_current_user_id();
$status = bp_course_get_user_course_status($user_id,$course_id);
if($status==5){
$html = '<input type="submit" class="course_button full button" value="'.__('HALF WAY','vibe').'">';
                      wp_nonce_field('continue_course'.$user_id,'continue_course');
}
return $html;
}