\drupal_access_denied
function
Generates a 403 error if the request is not allowed.

Generates a 403 error if the request is not allowed.

Comments

Anonymous’s picture

If you want to return the error 404 page (page not found), see the function drupal_not_found().

sylvain lavielle’s picture

I think this function introduce possibility of confusion usage : This function only render an access denied page but will not stop drupal normal render process.

So, for example, if you want to restrict a node access in a "last chance" test just before displaying it (test implemented in the hook_nodeapi at $op=='view') so you will need to do :

drupal_access_denied();
module_invoke_all('exit');
exit();

If you do not, drupal will output 2 pages stacked : The access denied page and the page you want to restrict access.

er.pushpinderrana’s picture

Before look into your solution, I was digging into code and doing a lot of research for this. I was also getting 2 pages issue as you explained and get resolved from your code.

Thanks!!!