How do I go about adding a user login section on the access denied page? I want to be able to give people a chance to login easily if they clicked on a restricted link before logging in.

Alternatively, is there a way to set the access denied page to automatically forward to another page after a set amount of time?

Also, is there a php statement that would allow me to determine if a user is currently logged in so I could display certain information on a page only if they're logged in?

Comments

JirkaRybka’s picture

First thing you surely know: You can create your own page, and type its URL-alias into admin settings, to show that page in "access denied" case.

To add login to this, I would edit the visibility of login sidebar-block, to be visible on this custom "access denied" page. These are simple suggestions, just to ensure you didn't forget :-)

Forwarding to another page after some time - I don't remember exactly, but there's some code to do this, which you can include into the body-HTML-text of your page.

To determine whether the user is logged in or not, you can set your page's text format (filter) to php-code and include something like this:

<?php
  global $user;
  if ($user->uid) {
      // Any php code you like to execute on this page for logged-in user only
     ?> Or any text paragraph to be shown, like this... <?php
  }
  else {
      // Any php code for NOT logged-in user
      ?> Or a text... <?php
  }
?>

But of course - be cautious while using the php-code option.

grippat’s picture

Thank you for the info JirkaRybka. I had no idea you could set a custom page for drupal to go to in the case of denied access. I'm pretty new to drupal so I'm still learning.

navs’s picture

I added index.html as my access denied page in admin settings. It isnt showing up. What do I do?