Approve, Spam, Delete and Unapprove Comment Links on Frontend

I am trying to get this answer to work as I need to be able to manage comments from the frontend.

The links are there, but I am still re-directed to the wp admin area to delete.

Here’s the code:

add_filter( ‘edit_comment_link’, ‘t5_comment_mod_links’, 10, 2 );
function t5_comment_mod_links( $link, $id )
{
$template = ‘ <a class=”comment-edit-link” href=”%1$s%2$s”>%3$s</a>’;
$admin_url = admin_url( “comment.php?c=$id&action=” );
$link .= sprintf( $template, $admin_url, ‘cdc&dt=spam’, __( ‘Spam’ ) );
$link .= sprintf( $template, $admin_url, ‘cdc’, __( ‘Delete’ ) );
$comment = get_comment( $id );

if ( ‘0’ === $comment->comment_approved )
{
$link .= sprintf( $template, $admin_url, ‘approvecomment’, __( ‘Approve’ ) );
}
else
{
$link .= sprintf( $template, $admin_url, ‘unapprovecomment’, __( ‘Unapprove’ ) );
}
return $link;
}

Read more here:: Approve, Spam, Delete and Unapprove Comment Links on Frontend

Leave a Reply

Your email address will not be published. Required fields are marked *