Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( !function_exists( 'learn_press_course_content_summary' ) ) {
- /**
- * Display the content of a lesson in a course content
- * @return int
- */
- function learn_press_course_content_summary() {
- $lesson_id = isset( $_GET['lesson'] ) ? $_GET['lesson'] : '';
- echo $lesson_id;
- // this doesn't work
- // $book_id = isset( $_GET['book'] ) ? $_GET['book'] : '';
- // echo $book_id;
- global $post;
- // ensure that we are passing the lesson correctly
- if ( $lesson_id && ( 'lpr_lesson' == get_post_type( $lesson_id ) ) && ( $lesson = get_post( $lesson_id ) ) ) {
- //check if user enrolled this course or not
- $course_id = get_the_ID();
- $user_id = get_current_user_id();
- $user_courses = learn_press_get_user_courses( $user_id );
- $enrolled = false;
- if ( isset( $user_courses ) && is_array( $user_courses ) ) {
- $enrolled = in_array( $course_id, $user_courses );
- }
- //if( !$enrolled && ! learn_press_is_lesson_preview( $lesson_id ) ) {
- if ( !learn_press_user_can_view_lesson( $lesson_id ) ) {
- echo "You have to enrolled to see lesson content";
- do_action( 'learn_press_course_content_course' );
- return 0;
- }
- // setup lesson as global post so we can uses the template function as in the loop
- $post = $lesson;
- setup_postdata( $post );
- do_action( 'learn_press_course_content_lesson', $post );
- // now reset the post to the course
- wp_reset_postdata();
- } else {
- do_action( 'learn_press_course_content_course' );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement