You are here

function forum_access_init in Forum Access 5

Same name and namespace in other branches
  1. 6 forum_access.module \forum_access_init()

Implementation of hook_init().

Deny access to forum if the user does not have access to it.

File

./forum_access.module, line 458
forum_access.module

Code

function forum_access_init() {
  if (!function_exists('user_access')) {

    // page is cached; bail.
    return;
  }
  if (!user_access('administer forums') && arg(0) == 'forum' && is_numeric(arg(1))) {
    global $user;
    if (!forum_access_access(arg(1), 'view')) {
      drupal_access_denied();
      module_invoke_all('exit');
      exit;
    }
  }
}