Skip to content

Instantly share code, notes, and snippets.

@greggles
Created September 26, 2011 20:23
Show Gist options
  • Save greggles/1243299 to your computer and use it in GitHub Desktop.
Save greggles/1243299 to your computer and use it in GitHub Desktop.
1290624_example2
<?php
//
function example_module_menu() {
// Allow admins to delete a comment at /example-delete-comment/CID.
$items['example-delete-comment'] = array(
'title' => t('Delete a comment'),
'page callback' => 'example_module_callback',
'access arguments' => array('administer comments'),
'type' => MENU_CALLBACK
);
return $items;
}
/**
* Comment delete. Menu definition confirms the user has administer comments.
*/
function example_module_callback($cid) {
$output = '';
// Load the comment.
$comment = comment_load($cid);
// If the comment exists, delete it.
if ($comment->cid) {
comment_delete($comment);
drupal_set_message("Deleted <em>$comment->subject</em>, comment ID $comment->cid");
}
drupal_goto('');;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment