Auto delete comment if Contains

It is better to use ‘comment_post’ action for this purpose, it is fired when the comment is saved in database: add_action(‘comment_post’, ‘my_comment_post_callback’, 10, 3); function my_comment_post_callback($comment_id, $comment_approved, $commentdata) { if (strpos($commentdata[‘comment_content’], ‘dog’) !== false) { $post_url = get_permalink($commentdata[‘comment_post_ID’]); wp_delete_comment($comment_id, true); wp_redirect($post_url); exit; } }

How unrequire comment text in wordpress post

I solve it: step 1 – insert a random number in text body, because WordPress prevent users that duplicate comments. step 2- set display:none to textarea of comment field Finally copy this code in functions.php: add_filter( ‘comment_form_field_comment’, ‘set_default_comment_text’, 10, 1 ); function set_default_comment_text() { $post_id = get_the_title(); global $current_user; get_currentuserinfo(); $comment_rand = rand(10,100000); $comment_field = … Read more

comments.php keep comment date/time but remove date/time’s #hyperlink

To keep the date/time text, you have to do minor modification in comments.php just add call back argument in wp_list_comments function. <?php wp_list_comments( array( ‘callback’ => ‘custom_format_comment_listing’ ) ); ?> Then add Following code in your functions.php file. you can modification other html as per your design. <?php function custom_format_comment_listing($comment, $args, $depth) { $GLOBALS[‘comment’] = … Read more

How to auto empty comment trash after X days

When deleting a comment it’s possible to use the second input argument: wp_delete_comment( $comment, $force_delete = true ) to delete it permanently and avoiding the trash bin. You could try to adjust your scheduled script accordingly. There’s also the EMPTY_TRASH_DAYS constant, that’s default set to empty the trash bin after 30 days, but it will … Read more

How to moderate (manually approve) comments of a specific (registered) User

If you are comfortable with coding, you could try a custom filter based on the WP_Comment object. Perhaps something like the following: function wpse_wp_insert_comment($id, $comment) { // Add your user_id, or use email address instead. if ( empty($comment->comment_author ) || $comment->user_id!== 1 ) wp_set_comment_status( $comment, ‘hold’ ); } add_action(‘wp_insert_comment’, ‘wpse_wp_insert_comment’, 10, 2); -Or … // … Read more

How to call my custom WordPress Comment form without getting the comments?

Yes, You can customize the comment form with the Bootstrap 4. You just need to do some edits with bootstrap classes and HTML. $args = array( ‘comment_field’ => ‘<p class=”comment-form-comment”><label for=”comment”>’ . _x( ‘Comment’, ‘noun’ ) . ‘</label><textarea id=”comment” name=”comment” cols=”45″ rows=”8″ aria-required=”true”></textarea></p>’ ‘fields’ => apply_filters( ‘comment_form_default_fields’, array( ‘author’ => ‘<p class=”comment-form-author”>’ . ‘<label for=”author”>’ … Read more

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