I am writing my own 403 page, and would like to redirect the user to the login page if the user is not logged in. I use this code in a page callback, but when I am viewing an unauthorized page (say /user/1
) as anonymous user, I got infinite redirect to /user/1
.
function MODULE_membercheck() {
global $user;
if (!$user->uid) {
//drupal_goto('user/login', array('query' => array('destination' => 'member/check')));
drupal_goto('user/login'); //these two lines won't work
return;
}
// other stuff.
}
update
It is quite easy to reproduce the problem. Just create a module and add a menu (member/check
), and redirect anonymous user to login page in the page callback
function. Then set the default 403 page to this menu entry, and try to open an unauthorized page.