How to delete a comment via an HTTP GET link in an email On my site, moderators are notified of comments via email whenever a new comment is posted. I would like to offer them a one-click approve/delete feature directly from the email.

There is an approve comment link, so I can easily put that link into the email for them to approve the comment directly.

However comments are deleted via a form - an HTTP post - so I can't do that from a link in an email as far as I know. At least that's how it is on my site - not sure whether the form behaviour is normal or is because I have Mollom installed.

Is there a way to delete a comment directly from a link in an email?
This will do it.

Obviously you don't want to allow just anyone to delete any comment.

The authentication step is to require the user to be logged in with "administer comments" permission.

Alternatively, you could perhaps use a token in the querystring to check access to delete the comment.

/**
 * Implements hook_menu
 */
function MY_MODULE_menu() {

  $items['action/comment/%/delete'] = array(
    'title' =&gt; 'Delete comment',
    'page callback' =&gt; 'MY_MODULE_action_comment_delete',
    'page arguments' =&gt; array(2),
    'access arguments' =&gt; array('administer comments'),
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}

/**
 * Menu callback
 * Delete comment via GET request
 */
function MY_MODULE_action_comment_delete($cid){

  try{
    // Delete the comment
    comment_delete($cid);
    drupal_set_message(t('The comment and all its replies have been deleted.'));
    watchdog('MY_MODULE', 'Deleted comment @cid and its replies.', array('@cid' =&gt; $cid));
    // Clear the cache so an anonymous user sees that his comment was deleted.
    cache_clear_all();
  }catch(Exception $e){
    drupal_set_message(t('There was a problem deleting the comment.'));
    watchdog_exception('MY_MODULE', $e);
  }

}


The path to delete a comment would then be:

http://www.example.com/action/comment/12/delete

Where "12" is the comment cid.