Inapproriate redirection

Question

Below is a part of the code of a plugin. I modified to add the else part. However, I’m noticing some weird behaviour. Before adding the else part, the first part of the code was properly executing whether or not the user is logged in. After adding the else part, if the user is not logged, the else part is properly executed. However, even if the user is logged, the else part still continues to execute. As far as I know, header('Location: /login/'); will execute at the server level and there will be not caching done at the client level. Any reason for this behaviour ?

if ( is_user_logged_in() ) {
        echo is_user_logged_in() ? 'true' : 'false';
        $priority_user_role = UM()->roles()->get_priority_user_role( um_user( 'ID' ) );
} else {
        header('Location: /login/');
        exit;
}
0
, , Noor 2 years 2019-11-23T09:27:03-05:00 0 Answers 82 views 0

Leave an answer

Browse
Browse