I wanted non-logged-in users who got "access denied" and needed to log in to be sent back to the page they were on when they got the "access denied" message. I installed this module to do that, but I could never get it to work - I used the "<current>"
parameter in the login rule but users just kept being sent to the /user page instead. After some Googling around the following did the trick. This prints a message with a "log in" link which redirects the user back to where they were after login, as well as a "register" link in case they need to register a new account. If they are in fact logged in they still get "access denied". Hope this helps...
<?php
global $user;
if ($user->uid == 0){
echo "Access Denied! To access this content, you probably just need to ";
print l("log in","user/login",array('query' => drupal_get_destination()));
echo " (or ";
print l("register","user/register");
echo " if you don't have a login). If you are having problems accessing a page, registering or logging in please ";
print l("contact us.","contact");
}
else{
echo "Access Denied! You don't have permissions to access this content. If you feel you should have access to it, please ";
print l("contact us.","contact");
}
?>
Comments
Comment #1
mithy CreditAttribution: mithy commentedOr the link to the login page needs to have the GET variable "current" set.