1

I need only members to be able to access the forums. I have researched this to death and from what I can tell, I need to have at least three modules to achieve this.

  1. Path access to block access to the core forum landing page at /forum (as it is not a node, entity nor view)

  2. Forum Access module to block the top level forum containers

  3. And Taxonomy Access or something like Node View Permissions to block access to the forum topics posts themselves.

Are you kidding me??? I need three permission modules just to stop anonymous users from looking and using the forums. Am I missing something here?

3
  • Old but still pretty relevant writeup of some options: lullabot.com/blog/articles/… - In addition to those, either the path access or custom permissions module for the forum landing page.
    – rooby
    Commented May 5, 2013 at 10:27
  • Also, watch out for some of the forum related blocks, which can sometimes still display (although basically empty) to users who don't have permissions to see them. So you have to make these blocks not display to roles that shouldn't see them.
    – rooby
    Commented May 5, 2013 at 10:28
  • I have submitted a patch to fix the taxonomy access module so it also blocks the forum container pages and there is dicussion regarding the main forum page. See drupal.org/node/2126753
    – rooby
    Commented Nov 4, 2013 at 3:53

1 Answer 1

4

To control access top level forum containers, forum topics and forum content, you should use the forum_access module (you mention it for blocking containers, but it can also be used to block access to forum topics and content).

However, after installing this and denying the anonymous user role access to forums, this user still has access to the forum landing page (he or she will see a message that it is necessary to log in to access forums).

If you also need to block access to the core forum landing page, you need to add a small custom module that uses hook_menu_alter to set up a custom callback function to check the user id. Since the anonymous user is assigned uid 0, you can use this to only grant users with a uid that is not 0 access to this menu item.

Here is all that is needed, stick this in noforumforanon.module:

/**
 * Implements hook_menu_alter.
 * Check access for forum menu item.
 */
function noforumforanon_menu_alter(&$items) {
  $items['forum']['access callback'] = '_accesscheck';
}

/**
 * Callback to disallow access for anonymous users.
 */
function _accesscheck(){
  global $user;
  return $user->uid;
}

And this in noforumforanon.info:

name = No Forum for Anonymous
description = Blocks anonymous from accessing the forum landing page.
package = Access control
core = 7.x

Put both files in a directory named noforumforanon below site/all/modules, enable and refresh cache, and the landing page shall be gone for anonymous.

3
  • No need to write custom code if you use the path access or custom permissions modules. Especially if you are already using those modules for other reasons. Also, if you need complex permissions or area already using it elsewhere, TAC can be used in place of forum access. Shouldn't need both at once though.
    – rooby
    Commented May 5, 2013 at 10:25
  • Actually I was wrong, TAC doesn't help with the forum category pages, only individual forum post pages, you do need either custom code or forum access or similar. I may investigate a patch for TAC to make this work.
    – rooby
    Commented Nov 4, 2013 at 2:24
  • See drupal.org/node/2126753
    – rooby
    Commented Nov 4, 2013 at 3:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.