• Hi,

    I want to display courses in sidebar menu along with an icon (check or cross) indicating whether the course is completed or not. Is there a shortcode or some other php way to pull out this kind of data? The closest is [namaste-mycourses] shortcode which displays the status of courses it lists, however I had no luck with pulling out the pure status code.

    I also need it to change the message displayed on a page that lists all the courses. Right now it bases on [namaste-condition is_enrolled=1 course_id=XXX], however it doesn’t take into account that the course is completed in full.

    Regards,
    Michal

    • This topic was modified 5 years, 9 months ago by pzo3xic.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter pzo3xic

    (@pzo3xic)

    I just come up with a workaround:

    function course_1_completed_check_shortcode($atts = [], $content = null) {
    $lesson1 = do_shortcode( '[namaste-lesson-status lesson_id="600"]' );
    $lesson2 = do_shortcode( '[namaste-lesson-status lesson_id="700"]' );
    if ($lesson1 =='Completed' AND $lesson2 =='Completed') {
    	$content = 'Course completed <span class="oi oi-check"></span>';
    	return $content;
    	}
    else
    	return $content;
    	}
    add_shortcode( 'course_1_completed_check', 'course_1_completed_check_shortcode' );

    the above is in functions.php

    then in lesson HTML I use:

    <div class="alert alert-info">[course_1_completed_check]You joined this course. See lessons below.[/course_1_completed_check]</div>
    which will display that user has enrolled but if completed all lessons it displays “Course completed”.

    The above involves a lot of work for a single course and it also means I won’t be able to delegate creating courses to others. Please don’t think of it as final solution.

    • This reply was modified 5 years, 9 months ago by pzo3xic.
Viewing 1 replies (of 1 total)
  • The topic ‘Get course status (completed or not) in php’ is closed to new replies.