Hi I'm trying to make it easier for site staff to mark comments as spam and delete them in the comments template. I've done the delete link:
<?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
$url = clean_url(wp_nonce_url( "/wp-admin/comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ));
echo "<a href='$url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('(Delete)') . "</a> ";
} ?>
But I can't work out the Spam link/unapprove
Any ideas?
stevenoi
Member
Posted 2 years ago #
Spam is (almost) the same as deleting the comment, so you won't need an extra link, the follow code will unapprove/approve, but it's very much...
<?php if ($comment->comment_approved == '0') : // WILL DISPLAY IF THE COMMENT IS UNAPPROVED ?>
<?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
$url = clean_url(wp_nonce_url( "/wp-admin/comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ));
echo "<a href='$url'>" . __('Approve') . "</a> ";
} ?>
<?php else : // WILL DISPLAY IF THE COMMENT IS APPROVED ?>
<?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
$url = clean_url(wp_nonce_url( "/wp-admin/comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ));
echo "<a href='$url'>" . __('Unapprove') . "</a> ";
} ?>
<?php endif ; ?>
lumilux
Member
Posted 2 years ago #
The above code is now returning
Your attempt to approve this comment: “190082” has failed.
Please try again.
Any idea how I need to change it?