HowTo: Display the real login page for anonymous on 403
Last modified: May 28, 2009 - 03:04
- Make 'denied' the 403 page.
- While you could pull the login form as the login block does and 4.7 and onwards it automatically submits -- but the registration tab would not appear. Solving this is very difficult, see http://drupal.org/node/88707 for further details (D6 solved this by rehauling the menu system from ground up). Add this to any hook_menu implementation in the $may_cache part. This is extremely important, this part must be cached.
<?php
$items[] = array(
'access' => !$user->uid,
'path' => 'denied',
'callback' => 'mymodule_denied',
'type' => MENU_CALLBACK,
);
?> - To your module, add:
<?php
function mymodule_denied() {
global $user;
if ($user->uid) {
return t('Access denied');
}
drupal_goto($_GET['q'], 'login=1');
}
?> - To settings.php add
<?php
function custom_url_rewrite($op, $result, $path) {
if ($op == 'source' && !empty($_GET['login'])) {
return 'user/login';
}
return $result;
}
?>
Another Option
Another way of doing this is with panels. http://www.proofgroup.com/blog/2008/sep/drupal_combining_login_registrat...
