Skip to content

Instantly share code, notes, and snippets.

@unaibamir
Created September 20, 2021 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unaibamir/f1efa4a8c45746492ef958dafb84f5a1 to your computer and use it in GitHub Desktop.
Save unaibamir/f1efa4a8c45746492ef958dafb84f5a1 to your computer and use it in GitHub Desktop.
learndash gradebook issue
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