Setting a Course End Date

Home Forums Legacy Support Support queries Setup issues Setting a Course End Date

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #244224
    kamhang
    Participant
    Hi, I follow the instruction here to set a course end date. I add two pieces of code in customizer_class.php, but my site crashed, any idea? <?php /* Plugin Name: WPLMS Customizer Plugin Plugin URI: http://www.Vibethemes.com Description: A simple WordPress plugin to modify WPLMS template Version: 1.0 Author: VibeThemes Author URI: http://www.vibethemes.com License: GPL2 */ /* Copyright 2014  VibeThemes  (email : [email protected]) wplms_customizer program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. wplms_customizer program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with wplms_customizer program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */ include_once 'classes/customizer_class.php'; if(class_exists('WPLMS_Customizer_Plugin_Class')) { // instantiate the plugin class $wplms_customizer = new WPLMS_Customizer_Plugin_Class(); } 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')); add_action('wplms_course_subscribed',array($this,'set_expiry_end_date'),10,2); add_filter('wplms_course_creation_tabs',array($this,'switch_wplms_front_end_tabs123'),1); 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!=''){ $end_date= date_i18n( get_option( 'date_format' ),strtotime($end_date)); $extra = array('end_date'=>'
    • <i>'.$end_date.'</i>End Date
    '); 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 'Course ended !'; } } function set_expiry_end_date($course_id,$user_id){ $end_date=get_post_meta($course_id,'vibe_end_date',true); $existing_time=get_user_meta($user_id,$course_id,true); $offset = get_option('gmt_offset'); $end_date = strtotime( $end_date); $end_date = $end_date + ($offset * 3600); $effectove_time = $end_date; if(!empty( $end_date) && time()< $effectove_time){ update_user_meta($user_id,$course_id,$effectove_time); } } function switch_wplms_front_end_tabs123($settings){ $fields = $settings['course_settings']['fields']; $arr=array(array( // Text Input 'label'    => __('Course End Date','vibe-customtypes'), // <label> 'desc'    => __('Date from which Course End','vibe-customtypes'), // description 'id'    => 'vibe_end_date', // field id and name 'type'    => 'date', // type of field )); array_splice($fields, (count($fields)-1), 0,$arr ); $settings['course_settings']['fields'] = $fields; return $settings; }
    #244225
    kamhang
    Participant
    Hi, Sorry, it seems that something wrong in my post How can i show you the content of php file?
    #244286
    Veronica
    Moderator
    hi, you can simply make use of this setting to set the end date for the course: http://prntscr.com/raa4a8 in the EDIT COURSE section. you can revert back if I misunderstood your query.
    #244329
    kamhang
    Participant
    Hi Veronica, That is exactly I want to set. But in the course section, I see all fields except course end date. Any prerequisite setting in order to show course end date?
    #244373
    Veronica
    Moderator
    YES, the above is this the result of the code provided here: https://wplms.io/support/knowledge-base/setting-a-course-end-date/ maybe you have not followed the instruction carefully/you have misplaced the code. add the code like this: http://prntscr.com/raotdm http://prntscr.com/raouxa please try the above one and then let us know. if you are not able to do the same then I will check it. I have tried to log in with your previous credentials but they are not working at all so please provide the working one if you are not able to apply the above code.
    #244621
    kamhang
    Participant
    This reply has been marked as private.
    #244635
    Veronica
    Moderator
    This reply has been marked as private.
    #244642
    Veronica
    Moderator
    BIG MISTAKE!!!! you have added the code in the WPLMS-CUSTOMIZER.PHP you have to add the code in the CUSTOMIZER_CLASS.PHP GOTO>>WPLMS-CUSTOMIZER PLUGIN>>CLASSES>>CUSTOMIZER_CLASS.PHP this is what you exactly missed here. refer this: http://prntscr.com/rbu73e
    #244658
    kamhang
    Participant
    This reply has been marked as private.
    #244665
    Veronica
    Moderator
    I have updated the path in the TIP. but as you know, it was very clear that we have to add the code in customizer-class.php anyways it is resolved now. BIG CHEERS! closing the topic.  
Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Setting a Course End Date’ is closed to new replies.