Okay
  Public Ticket #3630173
Hide Course
Closed

Comments

  • UMM started the conversation

    When we don't use the theme, the WPLMS option in the Admin menu no longer appears. I would like to know how I can hide a course, since with a non-WPLMS theme, I no longer have this option.

    Thank you

  • [deleted] replied

    How to add code in wplms customizer plugin


    change the 50,40,60 here with actual course ids separated by comma in the below code


    add this code in your wplms-customizer.php file in wplms customizer plugin : 


    function vibebp_get_option_custom(){
        return [50,40,60];//change the 50,40,60 here with course ids
    } add_filter('bp_course_total_count','hidden_courses');
    add_filter('wplms_carousel_course_filters','wplms_exlude_courses_directroy');
    add_filter('wplms_grid_course_filters','wplms_exlude_courses_directroy');
    add_filter('vibe_editor_filterable_type','wplms_exlude_courses_directroy');
    add_filter('bp_course_wplms_filters','wplms_exlude_courses_directroy');
    add_filter('vibe_related_courses','wplms_exlude_courses_directroy');
    add_filter('wplms_show_instructor_courses','wplms_exlude_courses_from_inst_profile'); add_filter('pre_get_posts','wplms_exlude_courses_from_directroy');
    add_filter('pre_get_posts','wplms_exclude_courses_authors'); function wplms_exlude_courses_from_inst_profile($args){
        if($args['post_type'] == 'course'){
            if(is_user_logged_in() && function_exists('bp_is_my_profile') && bp_is_my_profile()){
                return $args;
            }else{
                $excluded_courses=vibebp_get_option_custom('hide_courses');
                if(!empty($excluded_courses)){
                    if(!empty($args['post__not_in'])){
                      $args['post__not_in'] = array_merge($args['post__not_in'], $excluded_courses);
                    }else{
                      $args['post__not_in'] = $excluded_courses;  
                    }
                }
                
            }
        }
        return $args;
    }
    function hidden_courses($count){
        $excluded_courses=vibebp_get_option_custom('hide_courses');
        if(!empty($excluded_courses)){
            $count = $count - count($excluded_courses);
        }
        return $count;
    } function wplms_exlude_courses_directroy($args){
      if($args['post_type'] == 'course'){     if(isset($args['meta_query']) && is_array($args['meta_query']) && is_user_logged_in()){
            $user_id=get_current_user_id();
            foreach($args['meta_query'] as $query){
                if(isset($query) && is_array($query)){                 if($query['key'] == $user_id){
                        return $args;
                    }
                }
            }
        }     $excluded_courses=vibebp_get_option_custom('hide_courses');
          if(!empty($excluded_courses) && is_array($excluded_courses) && !(isset($args['author']) || isset($args['author_name']))){
            if(!empty($args['post__not_in'])){
              $args['post__not_in'] = array_merge($args['post__not_in'], $excluded_courses);
            }else{
              $args['post__not_in'] = $excluded_courses;  
            }
          } 
      }
      return $args;    
    } function wplms_exlude_courses_from_directroy($query) {
      if ( !$query->is_admin && $query->is_main_query() && $query->tax_query) {
        $excluded_courses=vibebp_get_option_custom('hide_courses');
        $query->set('post__not_in', $excluded_courses );
      }
      return $query;
    } function wplms_exclude_courses_authors($query){
      if ( !$query->is_admin && $query->is_author && $query->is_main_query()) {
        $excluded_courses=vibebp_get_option_custom('hide_courses');
        $query->set('post__not_in', $excluded_courses );
      }
      return $query;
    }
  •   UMM replied privately
  • [deleted] replied

    its working totally fine at my end . 

    Please share your site url and admin creds in private reply