Reply To: Delete post comments via front end
OK my code so far which partially works. I just need the page to reload or refresh to reflect that the comment has been deleted from the database. Any ideas?
if ( isset( $_POST['comment_delete_nonce'] ) ) {
if( wp_verify_nonce( $_POST['comment_remove_nonce'], 'comment-remove-nonce' ) ) {
set_query_var( 'commentid1', $_POST['commentid'] );
wp_delete_comment( get_query_var( 'commentid1'), true );
}
}
HTML form:
<form method="POST" action="" class="delete-comment-form">
<input type="hidden" name="comment_remove_nonce" value="<?php echo wp_create_nonce('comment-remove-nonce'); ?>" />
<input type="hidden" name="commentid" value="<?php comment_ID() ?>" />
<input type="submit" value="Delete" title="Delete" id="submit-btn" class="btn" />
</form>