Created
September 26, 2011 20:23
-
-
Save greggles/1243299 to your computer and use it in GitHub Desktop.
1290624_example2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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