'How to create a Lessons Playlist using LearnDash plugin?

I am creating a Playlist using LearnDash Plugin,
Below is my code,
This code works good but I can't get a video of a particular Lesson

Is there anyone who knows how to fix this?

add_shortcode( 'playlist', 'playlist_for_LMS' );

function playlist_for_LMS() {
        global $post;
    $user_id = get_current_user_id();
    $courses = learndash_user_get_enrolled_courses( $user_id, array(), true );
    $lessons = learndash_get_course_lessons_list( $courses[0],  $user_id,  array(), true );
    foreach ($lessons as $lesson){
         $postID    =   $lesson['post']->lesson_video_url;
         $postImage = get_the_post_thumbnail($lesson['post']->ID);
         $postTitle = $lesson['post']->post_title;
         $postLink = get_post_permalink($lesson['post']->ID);
        echo '<a href="'.$postLink.'">'.$postTitle.'&nbsp;'.$postID.'</a><br>';
    }
}


Solution 1:[1]

You use the below code and whats are the your output and go through your out put of fetched data. And also you can get errors if you have.

echo '<pre>';
print_r($lessons);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anjan