Questions & Answers

Learndash - Redirect back to last Topic/Lesson/Quiz when Course is Completed

I'm not familiar enough with WP hook / php code.

But what is the code/hook for redirected back to last Topic/Lesson/Quiz page/url when the course is completed?

By default, when the course is completed in Learndash, it will be redirected to course page / course url.

I have asked Learndash Support but I'm still not get the answer.

I have read this link

but most of these custom hooks for fixed/static page not dynamic page based on something.

Thank you very much.

Answers(1) :

you can try and add this to your theme's functions.php

add_filter( 'learndash_completion_redirect', 'my_custom_redirect', 10, 2 );

function my_custom_redirect( $link, $post ) {
    // Fetch the last visited topic/lesson URL
    $last_visited_url = get_user_meta( get_current_user_id(), 'last_visited_url', true );
    // check if there is last visited url
    if ( ! empty( $last_visited_url ) ) {
        return $last_visited_url;
    // if not return to default link
    return $link;