Check if user has enrolled in Sensei LMS Course on Lesson Page

You can show enrolment status on the lesson page using sensei actions and function. you can display status before/after content using action. just use proper action and paste code in active theme’s functions.php file.

To display before Lesson content use below action: add_action('sensei_single_lesson_content_inside_before','sensei_single_lesson_content_callback',100);

To display after Lesson content use below action: add_action('sensei_single_lesson_content_inside_after','sensei_single_lesson_content_callback',100);

Here is function which used for display status :

function sensei_single_lesson_content_callback($lessionid)
{
    $course_id = Sensei()->lesson->get_course_id( $lessionid);
    $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, $current_user->ID );
    if ( ! ( $is_user_taking_course  ) ) {
        echo "I am not taking course";
    } else {
        echo "I am taking the course";
    }
}

You can take reference from above code to get specific course id using $course_id = Sensei()->lesson->get_course_id( $lessionid); just replace $lessionid with $post->ID in single-lesson.php file.