WordPress shows logged out on front page
-
Hello,
I have a problem with my website https://www.4xbroker.cz
I created a simple custom user page for subscribers and I do not allow them to access backend.I am using the “Remove Dashboard Access” plugin to hide my backend and couple functions to effect the login and logout actions.
One of them is causing my logged in users with role subscriber to logout once clicked on the front page of the website: The function look likw this:function xbroker_login_redirect( $redirect_to, $user ) {
//is there a user to check?
$redirect_to = “https://www.4xbroker.cz/muj-ucet/”;
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if ( in_array( ‘administrator’, $user->roles ) ) {
// redirect them to the default place
return home_url();
} else {
return $redirect_to;
}
} else {
return $redirect_to;
}
}
add_filter( ‘login_redirect’, ‘xbroker_login_redirect’, 10, 3 );Can anyone see what the problem might be? Basically it works fine for me as an admin (hence the “in_array( ‘administrator’, $user->roles )” ) condition.. but every subscriber who clicks on homepage looks like he is logged out, but that when they click on any other menu link, they are logged back in. Any thoughts anyone?
- The topic ‘WordPress shows logged out on front page’ is closed to new replies.