How can I edit comment meta value before it is saved?

You can use “save_post” action-hook Add the code below into functions.php and enchance with your comment_meta code. function update_comments_meta( $post_id ) { // Do whatever add/update_comment_meta code you need } add_action( ‘save_post’, ‘update_comments_meta’ ); UPDATE. As an example i’ve attach code below. It performs on post save/update action fired. Code gets current post comments (all) … Read more

Use has_filter on comment_post

You’re adding the action on comment_form_before_fields in comment_form_logged_in_after. The latter is called only when the user is logged in, and the former is only called when the user is not logged in. You can add WordPress actions and filters at any time after WordPress is initialized. If you’re adding the action in a plugin, add … Read more

Update comment meta for all comments of specific post

Your approach will be very slow if there are N no of comments. Use following approach for much faster execution. global $wpdb; $sql=” SELECT GROUP_CONCAT( comment_ID ) AS ids FROM `wp_comments` WHERE comment_post_ID = “.$POST_ID; $ids = $wpdb->get_results($sql, ARRAY_A); if(isset($ids[0][‘ids’]) && $ids[0][‘ids’] != ”){ $wpdb->query(‘ UPDATE wp_commentmeta SET meta_value = 0 WHERE comment_id IN (‘.$ids[0][‘ids’].’) … Read more

Conditional tag for comments

The comments popup page contains a loop of the comments, which can be checked by an is comments popup() conditional, that returns either true or false. However, i don’t see this feature being used in modern development. This might be the only place containing a direct loop of comments. The $wp_query itself does not contain … Read more

Make every comment go to the spam folder

I don’t know of a way the default comment status can be changed, but there’s an action ‘comment_post’ that runs after comments are inserted that you could easily hook to set every new comment to have the ‘spam’ status: function set_new_comment_to_spam($commentId) { wp_set_comment_status($commentId, ‘spam’); } add_action(‘comment_post’, ‘set_new_comment_to_spam’, 10, 1); Add that to your functions.php

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