Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This code snippet was used on ZD ticket 274932 . It stops Sensei from automatically redirecting from the lesson to the quiz. Tags: Sensei Redirect, Lesson Redirect, Sensei Auto Redirect.
add_action('template_redirect', 'custom_remove_sensei_quiz_view');
function custom_remove_sensei_quiz_view(){
if( is_singular('quiz') ){
global $post;
//redirect back to the lesson page
$lesson_id = $post->post_parent;
//make sure this does not run again
$lesson_link = add_query_arg( 'sa', '1', get_permalink( $lesson_id ) );
wp_redirect( $lesson_link );
add_filter( 'wp_redirect', 'custom_sensei_stop_redirect_loop', 0, 2 );
function custom_sensei_stop_redirect_loop( $location, $status ){
$block_redirect = get_query_var( 'sa', '0' );
if( '1' == $block_redirect ){
$location = false;
return $location;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment