Hide Unit for Students

this setting will be added in unit section

refer:

 

add this code in wp-admin>>plugins>>plugin editor>>wplms customizer plugin>>wplms-customizer.php

 

add_filter('wplms_course_creation_tabs','hide_unit');
 function hide_unit($tabs){ 
foreach($tabs['course_curriculum']['fields'][0]['curriculum_elements'][1]['types'] as $k=>$unit){ 
$tabs['course_curriculum']['fields'][0]['curriculum_elements'][1]['types'][$k]['fields'][] =array(
 'label'=> __('Hide Unit','wplms' ),
 'type'=> 'showhide',
 'id' => 'vibe_instructor_only', 
'from'=>'meta', 
'value_type'=>'single',
 'style'=>'',
 'default'=> __('Hide Unit','wplms' ), 
'desc'=> __('Hide Unit for Students','wplms' ) );
 } 
return $tabs; 
} 
add_filter('bp_course_api_get_user_course_status_item',function($return, $request ){
 $body = json_decode($request->get_body(),true);
 if(!empty($body['token']) && is_numeric($request['course'])){
 $user = apply_filters('vibebp_api_get_user_from_token','',$body['token']); 
if(!empty($user)){ $item_id = $request['id'];
 $inst = get_post_meta($item_id,'vibe_instructor_only',true);
 if(!empty($inst) && $inst=='S'){ 
$inst_id = get_post_field('post_author',$item_id);
 if($inst_id!=$user->id){ $return =array(
'content'=>_x('Access not available','','wplms'),'meta'=>[]);
 } } } } 
return $return; },11,2);


Leave a Reply

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