function r4032login_redirect in Redirect 403 to User Login 5
Same name and namespace in other branches
- 6 r4032login.module \r4032login_redirect()
- 7 r4032login.module \r4032login_redirect()
MENU_CALLBACK for /4032login
Redirect anonymous users from 403 Access Denied pages to the /user/login page with a message explaining that they must login to view the requested page and a query string parameter appended to the url to return after login.
1 string reference to 'r4032login_redirect'
- r4032login_menu in ./
r4032login.module - Implementation of hook_menu().
File
- ./
r4032login.module, line 57 - Redirect denied pages to the user login form.
Code
function r4032login_redirect() {
global $user;
if ($user->uid == 0) {
if (variable_get('r4032login_display_denied_message', TRUE)) {
drupal_set_message(t('Access denied. You must login to view this page.'), 'error');
}
// using drupal_goto() with destination set causes a recursive redirect loop
header('Location: ' . url('user/login', 'destination=' . drupal_urlencode($_REQUEST['q']), NULL, TRUE), TRUE, 301);
exit;
}
elseif ($_REQUEST['q'] == 'user/register') {
print theme('page', theme('r4032login_user_register'));
exit;
}
else {
print theme('page', theme('r4032login_denied'));
exit;
}
}