Created
September 20, 2021 16:04
-
-
Save unaibamir/f1efa4a8c45746492ef958dafb84f5a1 to your computer and use it in GitHub Desktop.
learndash gradebook issue
This file contains hidden or 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
function test_redirect($query) | |
{ | |
if( is_user_logged_in() ) { | |
$userid = get_current_user_id(); | |
$user = wp_get_current_user(); | |
$original_id = $user->data->ID; | |
$roles = ( array ) $user->roles; | |
} | |
global $post; | |
$post_slug = $post->post_name; | |
$pageid = get_the_ID(); | |
//if($query->is_main_query() ) { | |
//echo $query; | |
if($query->get('post_type') == "sfwd-lessons" && in_array("subscriber",$roles) && $post_slug == "my-grades"){ | |
wp_set_current_user(3); | |
} | |
else if($query->get('post_type') == "sfwd-lessons" && in_array("group_leader",$roles) && $pageid == "45371"){ | |
wp_set_current_user(3); | |
} | |
else{ | |
wp_set_current_user($original_id); | |
} | |
//} | |
} | |
add_action('pre_get_posts', 'test_redirect'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment