Shortcode to show course duration in certificate


Warning: Undefined array key "c" in /home/wplmsio/public_html/support/wp-content/plugins/wplms_plugin/includes/vibe-shortcodes/shortcodes.php on line 3436

Warning: Undefined array key "u" in /home/wplmsio/public_html/support/wp-content/plugins/wplms_plugin/includes/vibe-shortcodes/shortcodes.php on line 3439

Warning: Undefined array key "c" in /home/wplmsio/public_html/support/wp-content/plugins/wplms_plugin/includes/vibe-shortcodes/shortcodes.php on line 3436

Warning: Undefined array key "u" in /home/wplmsio/public_html/support/wp-content/plugins/wplms_plugin/includes/vibe-shortcodes/shortcodes.php on line 3439

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

add_shortcode('certificate_course_duration', 'vibe_certificate_course_duration');
  function vibe_certificate_course_duration( $atts, $content = null ) {
     global $bp,$wpdb;
     $student_id=$_GET['u'];
     $course_id=$_GET['c'];
     $start_time = $wpdb->get_var($wpdb->prepare("SELECT date_recorded FROM {$bp->activity->table_name} WHERE type ='subscribe_course' AND item_id=%d AND component='course' AND (user_id=%d OR secondary_item_id=%d) ORDER BY id DESC LIMIT 1", $course_id,$student_id,$student_id));
     $expiry=get_user_meta($student_id,$course_id,true);
    if(isset($start_time) && $start_time)
      return  human_time_diff(strtotime($start_time),strtotime($expiry));
    else
      return '[certificate_course_duration]';
  }

Then use this shortcode in certificate : [certificate_course_duration]

Leave a Reply

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