Hide some courses in app

Tagged: ,

This topic contains 4 replies, has 3 voices, and was last updated by  Hilman Fajrian 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18491

    Hilman Fajrian
    Participant

    Hi,

    I have some courses made by Visual Composer. Since VC shortcode not rendered (yet) in my app, I need to hide these courses in app. In directory, filtered category, and student course category.

    Need assist. Thanks.

    #18538

    Alex
    Keymaster

    Well this can be done but we need some identifier to identify the courses which are built on visual composer .

    Maybe you can assign a category to them .

    #18541

    Hilman Fajrian
    Participant

    Good idea.

    But how to hide courses from certain category in app?

    Another idea is using course ID as identifier. How to hide courses in app using course ID?

    #18584

    Scott Lang
    Keymaster

    you can use  this

     

    add_filter(‘bp_course_api_get_featured_courses’,’unset_some_courses’,9999,2);

     

    add_filter(‘bp_course_api_get_courses’,’unset_some_courses’,9999,2);

    function unset_some_courses($posts, $request ){

    foreach ($posts as $key => $course) {

    $terms = get_the_terms($course->data[‘id’],’course-cat’);

    $cats = array();

    foreach ($terms as $k => $term) {

    $cats[] = $term->term_id;

    }

    if(in_array(your_course_id, $cats)){

     

    unset($posts[$key]);

    }

    }

    return $posts;

    }

     

    put this code to your wplms-customizer.php file(customizer plugin)

    • This reply was modified 4 months, 2 weeks ago by  Scott Lang.
    • This reply was modified 4 months, 2 weeks ago by  Scott Lang.
    #19125

    Hilman Fajrian
    Participant

    @scott

    Your code above does not work. The course I need to hide is still showing in app. The course ID is 2475. And this is my code. Need help to fix

    —-

    add_filter(‘bp_course_api_get_featured_courses’,’unset_some_courses’,9999,2);

     

     

     

    add_filter(‘bp_course_api_get_courses’,’unset_some_courses’,9999,2);

     

    function unset_some_courses($posts, $request ){

     

    foreach ($posts as $key => $course) {

     

    $terms = get_the_terms($course->data[‘id’],’course-cat’);

     

    $cats = array();

     

    foreach ($terms as $k => $term) {

     

    $cats[] = $term->term_id;

     

    }

     

    if(in_array(2475, $cats)){

     

     

     

    unset($posts[$key]);

     

    }

     

    }

     

    return $posts;

     

    }

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Template Design © VibeThemes. All rights reserved.