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

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

StatusFileSize
new773 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.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.