Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'learndash_completion_redirect', 'wbcom_learndash_quiz_continue_link', 10, 2 );
- function wbcom_learndash_quiz_continue_link( $link, $post_id ) {
- if( !empty( $post_id ) ){
- /* Get the Course id from Quize id */
- $course_id = get_post_meta( $post_id, 'course_id', true );
- $args = array(
- 'post_type' => 'sfwd-quiz',
- 'posts_per_page' => 1,
- 'order' => 'DESC',
- 'orderby ' => 'post_date',
- 'meta_key' => 'course_id',
- 'meta_value' => $course_id,
- 'date_query' => array(
- array(
- 'column' => 'post_date',
- 'after' => '24 hours ago',
- ),
- )
- );
- /* Get the Number of Quize which is published within 24 hours from assigned course */
- $course_quize = new WP_Query( $args );
- $course_quize_id = '';
- if ($course_quize->have_posts()) {
- while ( $course_quize->have_posts() ){
- $course_quize->the_post();
- $course_quize_id = get_the_ID();
- }
- }
- /* Check latest published quize id and completion Quize id both are same then redirct to another page */
- if ( $course_quize_id == $post_id ) {
- $link = 'https://google.com'; // Redirect latest quiz.
- }
- else{
- $link = 'https://wbcomdesigns.com/';
- }
- }
- return $link;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement