I have encountered a problem previously identified in node 122234 that seems to arise from calling drupal_access_denied inside a page template. The header and side bars of the page are rendered, and then the entire page (including header and sidebars) are rendered again in the page body. No solution to this problem was provided in node 122234. If an anonymous user tries to access certain pages, I want to give them an access denied error and present the login page. How do I do this from inside a page or node template if not with drupal_access_denied?

Thanks.

Comments

yoyoman’s picture

I'm getting the duplicate rendering from a different situation. If I register as a user with admin approval being required, an email gets sent to the user. If the user tries to use the one-time login URL before the admin has approved the account, this triggers the "drupal_access_denied()". I have not manually added a call to this function anywhere in my code, but I still get this duplicate rendering.

hardcoredev’s picture

Any update on this? I'm also getting a duplicate page when a new user clicks the one-time login and they were not approved yet.

timtrinidad’s picture

I know this is pretty late, but I stumbled upon this post and then found a solution right after. For those who find this in the future, just put an "exit;" call after "drupal_access_denied()", and that should stop the other parts of the page from rendering.

caspercash’s picture

Hey, I stumbled with the same problem as this one! Thank you very much! I made use of the suggestion you made. It's better late than never! Thanks!

gregstout’s picture

That saved me quite a bit of time. Thanks! It worked perfectly.

AgaPe’s picture

thanks a lot!!
tried
return drupal_access_denied();
but it didn't work

gianfrasoft’s picture

Try this:

return drupal_access_denied(); 
exit();

Web Software Engineer at
Insem S.p.A. - www.insem.it

gaurishankar’s picture

No change same problem.
return drupal_access_denied();
exit();
above code is use less.

Gauri Shankar