Enable Students subscribed to Course to view units from Curriculum

No longer required in 3.x : https://prnt.sc/s6hyxh

—–

1.  Go to WP Admin -> plugins -> editor – >Wplms customiser -> wplms-customizer.php

add_filter('wplms_curriculum_course_link','enable_course_students_view_units_curriculum');
  
 
function enable_course_students_view_units_curriculum($enable){
  
$user_id = get_current_user_id();
$course_id = get_the_ID();
  
if(wplms_user_course_active_check($user_id,$course_id))
return 1;
  
return $enable;
}
 
add_filter('wplms_direct_access_tounit','enable_access_tostudents',10,2);
function enable_access_tostudents($flag,$post){
    $user_id = get_current_user_id();
    $check = get_user_meta($user_id,$post->ID,true);
    if(!empty($check)){
        return 0;
    }
   return $flag;
}

The above will allow active users to see units which they have completed in course .

To allow access to all units for the students who have purchased the course please add the code given below : 

add_filter('wplms_curriculum_course_link','enable_course_students_view_units_curriculum1226',999,3);
function enable_course_students_view_units_curriculum1226($enable,$unit_id,$course_id){
  
$user_id = get_current_user_id();
  
if(wplms_user_course_active_check($user_id,$course_id))
return get_permalink($unit_id);
  
return $enable;
}
 
add_filter('wplms_direct_access_tounit','enable_access_tostudents1226',999,2);
function enable_access_tostudents1226($flag,$post){
 global $wpdb;
 $user_id = get_current_user_id();
 $course_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key= 'vibe_course_curriculum' AND meta_value LIKE %s LIMIT 1;", "%{$post->ID}%" ) );
 $check = wplms_user_course_active_check($user_id,$course_id);
 if(!empty($check)){
 return 0;
 }
 return $flag;
}