Show time spent by student on course admin

Please add this code in your wp-content/plugins/wplms-customizer/wplms-customizer.php file :


function custom_wplms_user_course_admin_member($student_id,$course_id){
global $bp,$wpdb;
$start_time = $wpdb->get_var($wpdb->prepare("SELECT date_recorded FROM {$bp->activity->table_name} WHERE type ='start_course' AND item_id=%d AND component='course' AND user_id=%d ORDER BY id DESC LIMIT 1", $course_id,$student_id));
if(!empty($start_time ))
echo '<span style="display:block">Time Spent : '. human_time_diff(strtotime($start_time),strtotime(current_time( 'timestamp' ))).'</span>';


Was this article helpful?

Related Articles


  1. learner4life

    Hi, is it possible to modify this code to get a sense of time spent in minutes and/or hours? Even though my course duration is in days, they are primarily video lectures so I want to get a sense of actually how much time are students spending time watching videos. And days/weeks become too vague for that.

  2. Shibon

    Is it possible to find the approximate time spent by user for studying course

Leave A Comment?