I am developing a plugin where I list all the available comments and then I want to have a links like Delete, Approve, Unapprove or Spam etc.

I have followed a thread here: Add delete, approve, spam Links to Comments. But while approving I get the error saying The link you followed has expired and I can't comment in that thread.

Can anyone please assist?

Below is my code:

$template = ' <a class="comment-edit-link" href="%1$s%2$s">%3$s</a>';
$admin_url = admin_url( "comment.php?c=$comment->comment_ID&action=" );
$link = '';
                            // Mark as Spam.
$link .= sprintf( $template, $admin_url, 'cdc&dt=spam', __( 'Spam' ) );
                            // Delete.
$link .= sprintf( $template, $admin_url, 'cdc', __( 'Delete' ) );
// Approve or unapprove.                             

if ( '0' === $comment->comment_approved )
   $link .= sprintf( $template, $admin_url, 'approvecomment', __( 'Approve' ) );
  $link .= sprintf( $template, $admin_url, 'unapprovecomment', __( 'Unapprove' ) );
echo $link;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.