User’s total comment count excluding comments on their own posts

I’m not aware of any WordPress functions that do this, so you can try to play with this kind of query (untested): function get_custom_user_comments_count( $uid ){ global $wpdb; $sql = “SELECT COUNT(*) as total  FROM {$wpdb->comments} as c   JOIN {$wpdb->posts} as p ON p.ID = c.comment_post_ID  WHERE c.comment_approved = ‘1’  AND p.post_status=”publish”   AND … Read more

Filter In Reply comments from WordPress Admin Panel

In your comments loop, skip the children: if( !empty( $comment->comment_parent ) ) { //if the comment has a parent, skip it as it’s not level 1 continue; } Edit: Above example would only help in the reading loop, below example should help in admin area: add_filter(‘the_comments’, ‘top_level_comments_filter’); function top_level_comments_filter($comments){ global $pagenow; if($pagenow == ‘edit-comments.php’){ foreach($comments … Read more

If modified on same day, show only time

Give this a try: if(get_the_modified_date(‘zY’)==date(‘zY’)) { the_modified_date(‘g:i a’); } else { the_modified_date(‘F j, Y’); echo ‘ at ‘; the_modified_date(‘g:i a’); } It checks that the modified date is the current day. If it is, it only displays the modified time. Otherwise it displays both the date and time.

Limit comments per user per post

I think that hook pre_comment_approved should be perfect in this case. Something like this should do the job: function my_pre_comment_approved($approved, $commentdata) { // you can return 0, 1 or ‘spam’ if ( $commentdata[‘user_ID’] ) { $args = array( ‘user_id’ => $commentdata[‘user_ID’], ‘post_id’ => $commentdata[‘comment_post_ID’] ); $usercomment = get_comments( $args ); if ( 1 <= count( … Read more

Automatically increase comment karma on comment save

The comment_karma field in the wp_comments table is something that has been in present in WordPress for a long time, but never utilized by the WordPress core itself. You can update it the same way any other comment field is updated, using update_comment(): $comment_data = array(); $comment_data[‘comment_ID’] = 1; $comment_data[‘comment_karma’] = 123; wp_update_comment( $comment_data );

Disallow img tag in comments?

You can strip images on display pretty easily. add_filter( ‘comment_text’, function($comment) { $allowed_html = array( ‘a’ => array( ‘href’ => array(), ‘title’ => array() ), ‘br’ => array(), ’em’ => array(), ‘strong’ => array() ); return wp_kses($comment, $allowed_html); } ); That will strip any tags not listed in the provided array. To specifically strip images … Read more

Add filter to comments loop?

It is hard to say what you need to hook into without knowing all the details but I think you may be able to use comment_text— more or less the the_content of comments. add_filter( ‘comment_text’, function ($comment) { return $comment.'<div>This is your special division</div>’; } ); If that isn’t quite right, take a look at … Read more