Hi,
I want to enable curriculum units in course page itself once purchase is done. Right now I am able to enable the unit link with following functions:
add_filter('wplms_curriculum_course_link','enable_course_students_view_units_curriculum'); and add_filter('wplms_direct_access_tounit','enable_access_tostudents',10,2)
But the problem I am facing is that on clicking the enabled unit link it doesn't go to course status page. It goes to that unit page. I want them to directly go to course status page.
Please help ASAP.
Thanks,
Ritesh
hey,
for that you do not need to do hard code. please try these settings in
wp-admin > lms > setting > general setting.
Refer:
http://prntscr.com/maklfw
Thanks ! I have already enabled those options from lms. Right now curriculum units which are completed are redirected to course status page.
My requirement is that when customer purchases the course, all the curriculum units should be enabled right away and should redirect to course status page.
Thank,
Ritesh
Hey there,
disable those settings and add this code :
Please paste this snippets in your wp-admin > plugins > editor > wplms-customizer plugin > wplms-customizer.php
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;
}
Hey,
Please let me know if it works so that i can close this one.