LifterLMS: Custom Page After a Student Completes a Course
Sends students to a page you choose, such as a survey or next-steps page, the next time they load a page after completing a LifterLMS course.
Opens WPIDE on
Code
if ( ! function_exists( 'llms_get_student' ) ) {
return;
}
// Course ID => URL. "default" applies to all other courses.
$wpide_llms_done_pages = array(
'default' => home_url( '/thank-you/' ),
);
add_action( 'lifterlms_course_completed', function ( $user_id, $course_id ) use ( $wpide_llms_done_pages ) {
$url = $wpide_llms_done_pages[ (int) $course_id ] ?? ( $wpide_llms_done_pages['default'] ?? '' );
if ( $url ) {
update_user_meta( (int) $user_id, 'wpide_llms_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_llms_done_redirect', true ) : '';
if ( $url ) {
delete_user_meta( $user_id, 'wpide_llms_done_redirect' );
wp_safe_redirect( $url );
exit;
}
} );
Notes
Map course IDs to URLs; the "default" entry covers every other course. Remove it to only redirect the courses you list.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.