How to prevent deleting of comments when deleting a post

To prevent the comment deletion hook into before_delete_post, and filter the query for associated comments so the deletion routine cannot find and delete those. PHP 5.3 required: add_action( ‘before_delete_post’, function( $post_id ) { add_filter( ‘query’, function( $query ) use ( $post_id ) { $find = ‘WHERE comment_parent=”; FALSE !== strpos( $query, $find . $post_id ) … Read more

Delete all user comments

Here are a few functions that make use of WP_Comment_Query to pull the user’s Comments, then loop through to find any replies, and trash them all. $current_user = wp_get_current_user(); $deleteReplies = true; $force_delete = false; deleteUserComments ( $current_user->ID, $deleteReplies, $force_delete ); If you want to test this without permanently trashing the items, you can reset … Read more

Comments waiting but no comments found

Try to check on DB level. This SQL should give a list of all spam comments (which I assume skräpposter means): SELECT * FROM `wp_comments` WHERE `comment_approved` = ‘spam’; If the SQL gives 0 lines, the issue is with WordPress counting those comments, but in fact there are none. If the SQL gives a list, … Read more

How to output a permanently delete comment link?

After briefly testing, the code snippet from OP seems to work: printf( ‘<a href=”https://wordpress.stackexchange.com/questions/269898/%s”>%s</a>’, wp_nonce_url( admin_url( “comment.php?c=$comment_id&action=deletecomment” ), ‘delete-comment_’ . $comment_id ), esc_html__( ‘Delete comment’, ‘text-domain’ ) ); But it looks like we have to make sure that the author is only deleting comments on hir own post, otherwise it will look for the edit_others_posts … Read more

Vanilla Forums as a replacement for WordPress comments?

The downside of using a forum system for comments, is that: the user probably has to register with the site to post a comment the user may not have single sign on ability through Vanilla you won’t be storing your comments in a system that can export them and import them into another commenting engine, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)