Inapproriate redirection


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/');
, , Noor 11 months 0 Answers 68 views 0

Leave an answer