Howto - Access Denied process

There are two general settings to control the access denied behavior

  1. modification of page.tpl.php
  2. page for the login

 

1 )  modification of page.tpl.php

add this line at the top to the file page.tpl.php of your theme

<?php global $user; if (!$user->uid && $title == 'Access denied') { header( 'Location: <URL>?destination=' . substr($_SERVER['REQUEST_URI'],1) ); } ?>

Replace the <URL> stuff with the page you want to forward to.
This page should be the one you create in step 2)

2) page for the login

  • create a new page
  • disable rich-text 
  • set input format to PHP code
  • add this code to the page and save it
    <p>
    Access has been denied<br />
    Please log in first.
    </p>
    <p>
    If you are already logged in you are not authorized to access this page.<br />
    </p>
    <p>
    Not a member, yet? Sign in <a href="/user/register">here.</a>
    </p>
  • insert the link to this page to the <URL> of 1)