If authenticated users don't have permission to create forum nodes, anon users are still invited to log in or register to post, even though they still won't be able to.

Looking at comment module, correct behaviour is to show nothing at all in this case.

CommentFileSizeAuthor
#2 788320.patch773 bytespfrenssen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Title: anon user is invited to log in to post in the forum, even if that won't allow them too » anon user is invited to log in to post in the forum, even if that won't allow them to

Comment module does it like this:

      // We only output a link if we are certain that users will get permission
      // to post comments by logging in.
      $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));

For forum, the same approach means checking any number of 'create NODETYPE' permissions. Anyone got any better ideas?

pfrenssen’s picture

FileSize
773 bytes

This patch fixes it. If the user is anonymous and would not be able to post new forum content after logging in, the text 'You are not allowed to post new content in the forum.' is shown instead of 'Log in to post new content in the forum.' to avoid false expectations.

pfrenssen’s picture

Status: Active » Needs review
joachim’s picture

Status: Needs review » Needs work

Other node types may be in the forum though -- see how forum_menu_local_tasks_alter() accounts for that, for instance.