The registration link on the "login or register to post comments" text generated by the comment module for anonymous users, is currently "user/register?destination=comment/reply/NID#comment_form" (when 'comment_form_location' == COMMENT_FORM_SEPARATE_PAGE).

This means that after a user fills the registration form and submits it, he is redirected to the comment/reply/NID page, while he is still logged out and has no access to publish comments.

The submitting of the registration form generates the message regarding details that are sent to the user's e-mail, which is just fine.
But being sent to the comment/reply page generates another message saying "You are not authorized to post comments" and then redirects the user to the node page. This message is confusing and useless.

The solution would be to change the 'destination' value of the 'register' link on comments to lead the user back to the node page, instead of 'comment/reply'.

On the function theme_comment_post_forbidden(), after setting $destination, I added the line:

$reg_destination = "destination=". urlencode("node/$nid");

And also patched the code following it:

    if (variable_get('user_register', 1)) {
      return t('<a href="%login">login</a> or <a href="%register">register</a> to post comments', array('%login' => url('user/login', $destination), '%register' => check_url(url('user/register', $reg_destination))));
    }
CommentFileSizeAuthor
#2 reg_destination47_1.diff.txt1.2 KBpwolanin

Comments

dries’s picture

Status: Needs review » Active

Thanks for the carully written report. This is not a real patch though so I'm updating the status to reflect this.

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new1.2 KB

Looks like the same bug is in 5.0/HEAD

patch attached for 4.7, but essentially the same should apply for 5.0/HEAD. Based on the comments above (I quickly tested it, but not thoroughly).

Arto’s picture

Note related issue #89059.

flk’s picture

Status: Needs review » Closed (duplicate)

duplicate of #89059 as stated above :).