Hide “Expired” courses from Course directory

You can add custom Classes to courses in course directory using this simple tip and using this class courses can be hidden from course directory.

1. Go to WP Admin -> Plugins -> Editor -> WPLMS Customizer->wplms_customizer.php

2. Add this code in __construct function:

add_filter('bp_course_single_item',array($this,'hide_expired_courses'),10,2);

3. Add this code in class:

function hide_expired_courses($class,$course_id){
  if(is_user_logged_in()){
    $user_id = get_current_user_id();
    $check = get_user_meta($user_id,$course_id,true);
    if(isset($check) && is_numeric($check)){
      if($check < time()){
        $class .=' expired_course';
      }
    }
  }
  return $class;
}

4. Now go to WP Admin -> Appearance -> customise -> Custom CSS and add this code :

#buddypress ul.item-list li.expired_course{display:none;}

Refer screenshots for reference :

 

 

 

Was this article helpful?

Related Articles