How is it possible for a module to detect when Drupal is outputting the "access denied" page?
I know how to do it with Drupal 6; I need to know how to do it with Drupal 7 or higher version.
|
||||
|
I do this in Boost 7.x. It's not pretty, but it does get the job done.
|
||||
|
You can set which pages are displayed when 403 & 404 errors occurs (admin/settings/error-reporting). I guess you can add a new page in your |
||||
|
Your module could intercept the value of "
And that's it, your module gets notified in a clean way (and invisible to the user) when "Access denied" is triggered. |
||||
|
Surely you could use PHP's The first element in the array returned will be the response code. If it contains '403' then Drupal returned an "access denied" page. I'm not sure where the best place to call it would be. Probably
|
||||
|
In Drupal 7, the function that returns the already set HTTP headers is drupal_get_http_header(), which requires the HTTP header name as parameter. Looking at authorize_access_denied_page(), and drupal_fast_404() code makes clear which values to pass to that function.
When the "Status" header starts with 403, then Drupal output an access denied page. Make sure the call to |
||||
|