Core::bp_ld_custom_continue_url_arr( $course_id,  $lession_list, string $course_quizzes_list = '' )

Get all the URLs of current course ( lesson, topic, quiz )

Description

Parameters

$course_id

(Required)

$lession_list

(Required)

$course_quizzes_list

(Optional)

Default value: ''

Return

(array) | string

Source

File: bp-integrations/learndash/core/Core.php

656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
public function bp_ld_custom_continue_url_arr( $course_id, $lession_list, $course_quizzes_list = '' ) {
    global $post;
 
    $course_price_type   = learndash_get_course_meta_setting( $course_id, 'course_price_type' );
    if ( $course_price_type == 'closed' ) {
        $courses_progress    = bp_ld_sync()->bp_get_courses_progress( get_current_user_id() );
        $user_courses = learndash_user_get_enrolled_courses( get_current_user_id() );
        $course_progress     = isset( $courses_progress[ $course_id ] ) ? $courses_progress[ $course_id ] : null;
        if ( $course_progress <= 0 && ! in_array( $course_id, $user_courses) ) {
            return get_the_permalink( $course_id );
        }
    }
 
    $navigation_urls = array();
    if ( ! empty( $lession_list ) ) :
 
        foreach( $lession_list as $lesson ) {
 
            $lesson_topics = learndash_get_topic_list( $lesson->ID );
 
            $course_progress = get_user_meta( get_current_user_id(), '_sfwd-course_progress', true );
            $completed       = ! empty( $course_progress[ $course_id ]['lessons'][ $lesson->ID ] ) && 1 === $course_progress[ $course_id ]['lessons'][ $lesson->ID ];
 
            $navigation_urls[] = array(
                'url'      => get_permalink( $lesson->ID ),
                'complete' => $completed ? 'yes' : 'no',
            );
 
            if( ! empty( $lesson_topics ) ) :
                foreach( $lesson_topics as $lesson_topic ) {
 
                    $completed = ! empty( $course_progress[ $course_id ]['topics'][ $lesson->ID ][ $lesson_topic->ID ] ) && 1 === $course_progress[ $course_id ]['topics'][ $lesson->ID ][ $lesson_topic->ID ];
 
                    $navigation_urls[] = array(
                        'url'      => get_permalink( $lesson_topic->ID ),
                        'complete' => $completed ? 'yes' : 'no',
                    );
 
                    $topic_quizzes = learndash_get_lesson_quiz_list( $lesson_topic->ID );
 
                    if( ! empty( $topic_quizzes ) ) :
                        foreach( $topic_quizzes as $topic_quiz ) {
                            $navigation_urls[] = array(
                                'url'      => get_permalink( $topic_quiz['post']->ID ),
                                'complete' => learndash_is_quiz_complete( get_current_user_id(), $topic_quiz['post']->ID ) ? 'yes' : 'no'
                            );
                        }
                    endif;
 
                }
            endif;
 
            $lesson_quizzes = learndash_get_lesson_quiz_list( $lesson->ID );
 
            if( ! empty( $lesson_quizzes ) ) :
                foreach( $lesson_quizzes as $lesson_quiz ) {
                    $navigation_urls[] = array(
                        'url'      => get_permalink( $lesson_quiz['post']->ID ),
                        'complete' => learndash_is_quiz_complete( get_current_user_id(), $lesson_quiz['post']->ID) ? 'yes' : 'no'
                    );
                }
            endif;
        }
 
    endif;
 
    $course_quizzes = learndash_get_course_quiz_list( $course_id );
    if ( ! empty( $course_quizzes ) ) :
        foreach( $course_quizzes as $course_quiz ) {
            $navigation_urls[] = array(
                'url'      => get_permalink( $course_quiz['post']->ID ),
                'complete' => learndash_is_quiz_complete( get_current_user_id(), $course_quiz['post']->ID) ? 'yes' : 'no'
            );
        }
    endif;
 
    $key = array_search('no', array_column( $navigation_urls, 'complete') );
    if ( '' !== $key && isset( $navigation_urls[$key] )) {
        return $navigation_urls[$key]['url'];
    }
    return '';
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.