# Tutor LMS: Redirect Students After They Complete a Course

> Sends students to a page you choose, such as a review request or next course, right after they click "Complete Course" in Tutor LMS.

- Type: PHP
- Runs: Run everywhere
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: tutor, redirect, courses
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/tutor-redirect-after-course-completion/

## Code

```php
if ( ! function_exists( 'tutor_utils' ) ) {
    return;
}

// Course ID => URL. "default" applies to all other courses.
$wpide_tutor_done_pages = array(
    'default' => home_url( '/thank-you/' ),
);

add_action( 'tutor_course_complete_after', function ( $course_id, $user_id = 0 ) use ( $wpide_tutor_done_pages ) {
    $user_id = $user_id ? (int) $user_id : get_current_user_id();
    $url     = $wpide_tutor_done_pages[ (int) $course_id ] ?? ( $wpide_tutor_done_pages['default'] ?? '' );

    if ( $user_id && $url ) {
        update_user_meta( $user_id, 'wpide_tutor_done_redirect', esc_url_raw( $url ) );
    }
}, 10, 2 );

add_action( 'template_redirect', function () {
    $user_id = get_current_user_id();
    $url     = $user_id ? get_user_meta( $user_id, 'wpide_tutor_done_redirect', true ) : '';

    if ( $url ) {
        delete_user_meta( $user_id, 'wpide_tutor_done_redirect' );
        wp_safe_redirect( $url );
        exit;
    }
} );
```

## Notes

Map course IDs to URLs; "default" applies to all other courses.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutor LMS: Redirect Students After They Complete a Course" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
