Anyone know how to add quick comment moderation links for users who have permission to add/edit posts and comments? (Upprove / Unappove / Edit / Spam / Trash ). Note: in my comments.php I call the loop with <?php wp_list_comments(); ?>
Leave a Reply
You must be logged in to post a comment.
Per default
wp_list_comments()
calls the classWalker_Comment
. Its methodstart_el()
callsedit_comment_link()
and here we find a filter for your question: It is called'edit_comment_link'
and it passes two variables, the link text and the comment ID, which we can use.The URLs to mark a comment as spam or to delete it are:
wp-admin/comment.php?c=1&action=cdc&dt=spam
for spam, andwp-admin/comment.php?c=1&action=cdc
for deletion.We can add a parameter
redirect_to=
to send us back to the post after the comment was trashed.Here is a sample plugin I just hacked together (GitHub address):
Screenshot with TwentyEleven (order reversed by the stylesheet):
This is what I use (added as a reference â toscho’s answer IS BETTER for many reasons):
Most themes already come with an “Edit” link, so I didn’t include that.
Example Preview:
In 2022, unfortunately, the accepted answer does no longer work… without some changes, at least. You now need to add a nonce or the action will be rejected as per protocol. But this can be amended:
And used like this, for example, although I strongly recommend adding
&redirect_to=
as well:Taken from the core wp-admin/comment.php.