Access The Last Opened Unit

This code will work in the following case:
1. If the user completed a unit.
2. Then Hit Back To Course Button
3. When again access the course, the user will fall on the last completed unit.
Paste this code in WPLMS Customizer Plugin

add_filter('wplms_get_course_unfinished_unit',function($unit_id,$course_id){
 $course_curriculum=bp_course_get_curriculum_units($course_id);
 if(!empty($course_curriculum) && count($course_curriculum)){
    $key = array_search($unit_id, $course_curriculum);
    if(!empty($key) && !empty($course_curriculum[$key-1])){
       $unit_id =$course_curriculum[$key-1];
    }
   
 }
 return $unit_id;
},99,2);

Leave a Reply

Your email address will not be published. Required fields are marked *