Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should not issue redirects when there is an access denied. That is a logical error in any web-framework. You should issue an "access denied" when you want to deny access. Just like you issue a "the content has moved there, please go there" when your content has moved. </p> <p>Instead of <code>drupal_goto()</code>, use <code>drupal_access_denied()</code>. If you truly want people to be redirected to another url, the place to do that, would be <strong>on the page that shows the denied access</strong>.</p> <p>That said, issuing a <code>drupal_access_denied()</code>, or, in fact, sending any header in <code>hook_init()</code> is plain wrong. From the <a href="http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_init/6" rel="nofollow">documentation</a>: «Perform setup tasks.» Sending headers is <em>not</em> a setup-task. Moreover, that same documentation warns about another potential problem with your approach: «This hook is not run on cached pages», in other words, once an adult visits a page, and it is cached, underaged visitors will not be redirected or denied access, they will get the cached page served.</p> <p>Now, on to what you <em>should</em> do: A module such as Taxonomy Access (Lite) or the more appropriate <a href="http://drupal.org/project/node_privacy_byrole" rel="nofollow">Node Privacy By Role</a> can be used to grant access to your content. Note that, by default, Views will not use these access: they will show lists of content, regardless of the access by the user: you will have to reconfigure all your views to either honor the access-rules or to be inaccassible entirely, to certain roles. In addition, you need to give "minors" a separate role: that way you can grant them different access then the people in rol "authenticated user" or even in "adult". You will need some mechanism to <a href="http://drupal.org/project/autoassignrole" rel="nofollow">automatically assign roles</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload