Redirecting on Access Denied Errors
Submitted by alan dawson on Sun, 2007/11/25 - 01:40.
Online Environment Development | Other discussion topics
Drupal gives ability to control access to content.
If a user hits some content that gives a 403 error ( access denied ) either because they have not got correct access rights,
or are anonymous it is possible to control what happens next.
This php snippet does just that.
<?php global $user; if ($user->uid) { print $user->name; ?>, <p>We apologize, but you do not have permission to access this page.</p> <p>If you feel that you have received this message in error, please contact us with specific details so that we may review your access to our web site.</p> <p>Thank You, Technology and Social Action web team</p> <?php } else { $dest = drupal_get_destination(); ?><p>The page you requested is available to logged in users only...</p> <div class="links">» <a href="/user/login?<?php print $dest ?>">login</a> or <a href="/user/register?<?php print $dest ?>">register</a> to view this page</div> <?php } ?>
For more ideas around this see http://drupal.org/node/59861