Show start date instead of remaining time in course button

Please add the following code in your wplms-customizer.php  file in wplms customizer plugin :

add_action('init','remove_old_notice',900);
function remove_old_notice(){
  remove_filter('wplms_course_button_extra','vibe_course_button_time_extra',10,2);  
}


add_filter('wplms_course_button_extra','custom_vibe_course_button_time_extra',10,2);
function custom_vibe_course_button_time_extra($extra,$course_id){
   $start_date=get_post_meta($course_id,'vibe_start_date',true);
   $timestamp = strtotime(date_i18n( get_option( 'date_format' ), strtotime( $start_date )));
   if(isset($start_date) && $timestamp > current_time('timestamp')){ 
       $extra .= '<span>'.__('COURSE STARTS ON ','vibe').date_i18n( get_option( 'date_format' ), strtotime( $start_date )).'</span>';
   }
   return $extra;
}

To replace the remaining time to start the course with the start date in course detail please add the given code and disregard the above :

add_action('init','remove_old_notice',900);
function remove_old_notice(){
  remove_filter('wplms_course_button_extra','vibe_course_button_time_extra',10,2); 
  remove_filter('wplms_course_details_widget','vibe_show_course_start_time_in_course_details'); 
}
 add_filter('wplms_course_details_widget','custom_course_start_time_in_course_details'); 
 function custom_course_start_time_in_course_details($course_details){
     $course_id = get_the_ID();
    if(function_exists('bp_course_get_start_date')){
      $start_date = bp_course_get_start_date($course_id);
    }else{
      $start_date=get_post_meta($course_id,'vibe_start_date',true);  
    }
    
    $timestamp = strtotime( $start_date );
    if(isset($start_date) &&  $timestamp  > time()){ 
        $time_remaining = date_i18n( get_option( 'date_format' ),$timestamp);
        $extra=array('start_time' => '<li><i class="i_course_time">'.$time_remaining.'</i>'.__('STARTS ON ','vibe').'</li>');
        array_splice($course_details, 1, 0, $extra);
    }
    return $course_details;
 }
 
add_filter('wplms_course_button_extra','custom_vibe_course_button_time_extra',10,2);
function custom_vibe_course_button_time_extra($extra,$course_id){
   $start_date=get_post_meta($course_id,'vibe_start_date',true);
   $timestamp = strtotime(date_i18n( get_option( 'date_format' ), strtotime( $start_date )));
   if(isset($start_date) && $timestamp > current_time('timestamp')){ 
       $extra .= '<span>'.__('COURSE STARTS ON ','vibe').date_i18n( get_option( 'date_format' ), strtotime( $start_date )).'</span>';
   }
   return $extra;
}

refer : http://prntscr.com/akz32h

Leave a Reply

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