Hey guys,

I met a problem when i want to redirect the user to the drupal_access_denied() page

The situation is that there is one template named 'page-xxx.tpl.php', and the url is localhost/xxx, then after going to this url, the template will be used.

And i want to make access control on this template, how?

My way is to
if(!in_array('role 1', $user->roles)){
drupal_access_denied();
exit;
}
in template.php.
But it give me the error 'Maximum function nesting level of '200' reached, aborting!...'
Why?

Any suggestions appreciated! Thanks

Comments

jaypan’s picture

Access should be done at the module level, not the theme level. Did you create the module that creates this page? If so, you will need to alter your hook_menu() and set the proper permission to it. If it's someone else's module, you can implement hook_menu_alter().

Contact me to contract me for D7 -> D10/11 migrations.

dani.latorre’s picture