Please follow the below instructions for course end date functionality:
1. Go to WP Admin -> Plugins -> Editor -> WPLMS Customizer -> customizer_class.php
2. Add the following code in the _construct function :
PHP Code:
add_filter('wplms_course_metabox',array($this,'wplms_custom_course_meta')); add_filter('wplms_course_details_widget',array($this,'wplms_custom_course_details_widget')); add_filter('wplms_take_course_page',array($this,'wplms_custom_take_course_page'),10,2); add_filter('wplms_course_product_id',array($this,'wplms_custom_take_course_page'),10,2); add_action('wplms_course_before_front_main',array($this,'wplms_custom_course_before_main'));
3. Add the following code in class :
PHP Code:
function wplms_custom_course_meta($course_meta){ $prefix = 'vibe_'; $course_meta[]=array( // Text Input 'label' => __('Course End Date','vibe-customtypes'), // <label> 'desc' => __('Date from which Course End','vibe-customtypes'), // description 'id' => $prefix.'end_date', // field id and name 'type' => 'date', // type of field ); return $course_meta; } function wplms_custom_course_details_widget($details){ $course_id = get_the_ID(); $end_date=get_post_meta($course_id,'vibe_end_date',true); if(isset($end_date) && $end_date!=''){ $extra = array('end_date'=>'<li><i>'.$end_date.'</i>End Date</li>'); array_splice($details, 1,0,$extra); } return $details; } function wplms_custom_take_course_page($link, $course_id){ $end_date=get_post_meta($course_id,'vibe_end_date',true); if(isset($end_date) && $end_date!='' && strtotime($end_date) < time()){ return '?error=end_date'; } return $link; } function wplms_custom_course_before_main(){ $error = $_REQUEST['error']; if(isset($error) && $end_date!='' && $error == 'end_date'){ echo '<div id="message" class="notice"><p>Course ended !</p></div>'; } }
Please check screenshot for reference: