Hi all.
This is what I'm trying to achieve.
- If the user is not logged in and they try to access a private page, they are taken to the login page. - If the user is logged in and they try to access a page they can't access, they are taken to an "access denied" page.
The first seems easy enough. I just changed the "Default 403 page" to user/login.
But, I can't figure out the second.
Any ideas?
I would create a dedicated node to handle "page 403" then I would put in there custom php like: <?php global $user; if ($user->uid == 0) { drupal_goto('user/login'); } else { echo 'Access denied'; }
?>
I think this would help you ;-) ----- Original Message ----- From: John Barreiros To: support@drupal.org Sent: Friday, December 14, 2007 3:11 PM Subject: [support] access denied page
Hi all.
This is what I'm trying to achieve.
- If the user is not logged in and they try to access a private page, they are taken to the login page. - If the user is logged in and they try to access a page they can't access, they are taken to an "access denied" page.
The first seems easy enough. I just changed the "Default 403 page" to user/login.
But, I can't figure out the second.
Any ideas?
------------------------------------------------------------------------------
-- [ Drupal support list | http://lists.drupal.org/ ]
Hi Nicolas,
I tried that, but it appears to put drupal into an infinite loop.
"The page isn't redirecting properly. Firefox has decided that the server is redirecting the request for this address in a way that will never complete."
My final code is... <?php global $user; if ($user->uid == 0) { drupal_goto('user/login'); } ?> <p>Access Denied</p>
On Dec 14, 2007 5:33 PM, Nicolas Tostin nicolast@logis.com.mx wrote:
I would create a dedicated node to handle "page 403" then I would put in there custom php like:
<?php global $user; if ($user->uid == 0) { drupal_goto('user/login'); } else { echo 'Access denied'; } ?>
I think this would help you ;-)
----- Original Message ----- *From:* John Barreiros johnbarreiros2@gmail.com *To:* support@drupal.org *Sent:* Friday, December 14, 2007 3:11 PM *Subject:* [support] access denied page
Hi all.
This is what I'm trying to achieve.
- If the user is not logged in and they try to access a private page, they
are taken to the login page.
- If the user is logged in and they try to access a page they can't
access, they are taken to an "access denied" page.
The first seems easy enough. I just changed the "Default 403 page" to user/login.
But, I can't figure out the second.
Any ideas?
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
If you are doing this in a theme, or on an init hook, you need to except the user/login page, otherwise you get infinite redirect loop.
<?php global $user; if (($user->uid == 0) && (!$_GET['q'] != 'user/login')) { drupal_goto('user/login'); } ?>
________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of John Barreiros Sent: Monday, December 17, 2007 12:08 PM To: support@drupal.org Subject: Re: [support] access denied page
Hi Nicolas,
I tried that, but it appears to put drupal into an infinite loop.
"The page isn't redirecting properly. Firefox has decided that the server is redirecting the request for this address in a way that will never complete."
My final code is... <?php global $user; if ($user->uid == 0) { drupal_goto('user/login'); } ?> <p>Access Denied</p>
On Dec 14, 2007 5:33 PM, Nicolas Tostin < nicolast@logis.com.mx> wrote:
I would create a dedicated node to handle "page 403" then I would put in there custom php like:
<?php
global $user;
if ($user->uid == 0) {
drupal_goto('user/login');
}
else {
echo 'Access denied';
}
?>
I think this would help you ;-)
----- Original Message -----
From: John Barreiros mailto:johnbarreiros2@gmail.com
To: support@drupal.org
Sent: Friday, December 14, 2007 3:11 PM
Subject: [support] access denied page
Hi all. This is what I'm trying to achieve. - If the user is not logged in and they try to access a private page, they are taken to the login page. - If the user is logged in and they try to access a page they can't access, they are taken to an "access denied" page. The first seems easy enough. I just changed the "Default 403 page" to user/login. But, I can't figure out the second. Any ideas?
________________________________
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]