Last active
December 7, 2015 08:13
-
-
Save woogist/89d1627fb6dc9a448d00 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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