Access denied messaging and behavior Currently my users are being redirected to a node after trying to first access that node's comment page (comment/reply/nid) via a link in a view.  This is because I've set it so you have to be logged in to leave a comment.  In the message area, on the node that they are redirected to, is an error message, "Error message: You are not authorized to post comments."  

I want to change this so that when an anonymous user accesses the comment/reply/nid she is presented with a login page and then directed back to the comment/reply/nid.

I've tried logintoboggin, but that doesn't seem to work.  This is possibly because an access denied message is being displayed, not a 403.

I have a view that displays links to comment on various nodes, and I tried altering the links in this view via hook_views_pre_render.  I was going to try and add a modal window containing a login form if the user was anonymous by taking a more html and js approach a la Twitter Bootstrap.  But I was unable to locate the link in the massive view array.  I was hoping for a render array to modify (add a class, add an attribute, etc).  Not even sure if this would be a "Drupal kosher" approach.

Any ideas?
You can do it in hook_views_pre_render() like this:

/**
 * Implements hook_views_pre_render().
 */
function MODULENAME_views_pre_render(&amp;$view) {
  if ($view-&gt;name == 'VIEWNAME') {
    if (!user_is_logged_in() &amp;&amp; !empty($view-&gt;field['FIELDNAME']-&gt;options['alter']['path'])) {
      $view-&gt;field['FIELDNAME']-&gt;options['alter']['path'] = 'user/login?destination=' . $view-&gt;field['FIELDNAME']-&gt;options['alter']['path'];
    }
  }
}


Where in this case I would say 'title' is your FIELDNAME.

This will, if the user is logged out, replace whatever you have for your link in the rewrite settings, with a link to the login page, with your original path as the query destination, which will be used to return you to that page after the login form is submitted.

Also, there is the modal_forms module, which might be worth trying for a pop-up solution.  However then you need to take them to the comment reply page after the modal form closes.