Home / comment / Add delete and spam actions
  • How to Add delete and spam actions

    no thumbnail sorry: Add delete and spam actions

    The first snippet of code should be added to your functions.php of your wordpress theme. Once added you will need to open comments.php and add the second snippet of code to the location you wish to display the delete and spam links. These links will only be displayed for users with the ability to edit posts.

    ( click code to copy )

    wordpress snippet : PHP - functions.php

    <>
    function delete_comment_link($id) {
      if (current_user_can('edit_post')) {
        echo '| <a href="'.admin_url("comment.php?action=cdc&c=$id").'">del</a> ';
        echo '| <a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'">spam</a>';
      }
    }
    
    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?
               delete_comment_link(get_comment_ID());
    ?>
    

    ( WordPress codex functions, hooks, in this snippet. )

    get_comment_ID, delete_comment, edit_post, current_user_can, user_can, comment_link, get_comment, comment_ID, admin_url,