I want to create a link to allow the user to reply a particular node and then redirect him back to the originating page. I use drupal_get_destination() do create the following link:

http://example.com?q=comment/reply/3&destination=originating_page

The resulting form has the following html:

<form action="?q=comment/reply/3"  accept-charset="UTF-8" method="post" id="comment-form">

The "destination" parameter is not included in the action and thus drupal does not redirect the user as required.

This bug does not occur if the user replies to a comment rather to the node itself. Thus the link:

http://example.com?q=comment/reply/3/4&destination=originating_page

produces the following html:

<form action="?q=comment/reply/3/4&amp;destination=originating_page"  accept-charset="UTF-8" method="post" id="comment-form">

The problem lies in the following piece of code in the end of the comment_form function in comment.module:

  if (empty($edit['cid']) && empty($edit['pid'])) {
    $form['#action'] = url('comment/reply/'. $edit['nid']);
  }

Temporarily changed it to:

  if (empty($edit['cid']) && empty($edit['pid'])) {
    if (isset($_REQUEST['destination'])) {
      $destination = '&' . drupal_get_destination();
    }
    
    $form['#action'] = url('comment/reply/'. $edit['nid']) . $destination;
  }

Comments

pshangov’s picture

Version: 6.4 » 6.6
dpearcefl’s picture

Is this still an issue using current Drupal 6?

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.