Yay! We got filters!
Wrapping the result of the $wpdb
comments query right into a filter callback (and a plugin) is the nice way of handling comments.
/* Plugin Name: »Kaisers« Comments without admin comments */
! defined( 'ABSPATH' ) AND exit;
add_filter( 'comments_array', 'wpse_61072_comments_without_admin', 20, 2 );
function wpse_61072_comments_without_admin( $comments, $post_id )
{
foreach ( (array) $comments as $index => $c )
{
// Add a limit
if ( 5 <= absint( $index + 1 ) )
return (object) $comments;
// Get the authors user data
$author = get_userdata( $c->user_id );
// Unset based on the standard/default capability
if ( user_can( $author->ID, 'manage_options' ) )
unset( $comments[ $index ] );
}
return (object) $comments;
}
This one should work (not tested).
Related Posts:
- How to wrap submit button of comment form with div
- How can I limit the number of comments per registered user per day?
- Showing comments only to same custom user role
- How to hide “Trackback” on paginated comments
- how to have 2 comments_template() in one post
- Passing arguments to wp_list_comments callback function
- customize comment form
- comments_template not working correcly in custom template files
- How can I show comments in random order?
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, func
- What does the “$depth” parameter in the Walker_Comment stand for?
- Add classname comment template from functions.php
- Customizing comments pagination for bootstrap
- comment_post action hook running on page load instead of after a comment is posted
- using comments_template() in custom single-portfolio.php
- how to properly use comments-template.php
- WordPress comments – how to check if comment still needs to be approved?
- Modify WordPress Comment From For AMP Html
- comments_number not displaying
- How to make comments private for commentor and post author
- Name of comment field differs on different sites
- The comment could not be saved. No comment_ID on comments
- How to display comment meta under each comment content
- How can I embed comments plugin to my own website?
- Custom comment field not showing when logged-in
- Custom comment link
- How to display replies to his comments in user profile of current user
- How to show a list of comments on home page from all posts?
- reply comment below the comment box without reload page
- How to call out the date of user’s first comment?
- How to pass settings to comment_form() if theme only uses comments_template()?
- How to add a class to comment submit button?
- How Can I display the Current Logged-In User’s Comment at the Top of the Comments Section in WordPress?
- Comments page id wp_list_comments
- reply to comment excerpt instead of author in comment title
- Redirect first time comments
- How to maintain changes to comment-template.php
- Display Comment Form on dedicated Page for each post
- Commentform – Hightlight invalid fields instead of prompting towards error page
- Auto approve all comments (editor)
- The last comments of a post for the author of that post
- Stop WordPress redirecting comment-page-1 to the post page?
- Importing old Disqus comments into WordPress
- How to add a class to the comment submit button?
- Comments screen in backend, how to disable email address of commenter for non admins
- Parent comment’s author name
- get_comments_number of depth-1 (Level 1) (1 post)
- How can I control the comment counts filtering my CPT replies?
- List Recent Comments from Across a Multi-site Network
- Can I store my custom comment_type into wp_comments table?
- Number of External Links in Comments – Moderation Option
- What is comment_karma?
- What are the additional fields in wp_comments used for?
- Enable Recent Comments widget to display comments on attachment posts
- Change allowed HTML tags for comments
- migrate comments from old database to new database
- Toggle nested comments
- Private replies for comments
- Show last n comments
- Threaded commenting: how to show threads by last active first?
- How to add a title field in comments?
- How to add attributes to the comment form tag?
- How to add replyToUrl schema.org to WordPress comments?
- Get comments from post and sort by commentmeta value
- Problems with comments callback (Argument #1 is not an array?)
- Can WordPress comments have titles and taxonomy?
- Comments system doesn’t like International domains
- How to call wp_list_comments() outside of the comments template?
- Polls with respective comments?
- Why does akismet prevent jetpack comments from appearing in my moderation queue? [closed]
- Problem with WordPress Comment
- Where are comment ratings stored?
- Comments change the template name
- I can’t post comment via REST API
- WordPress scruity issue – Totally disable all comments by CSS — secure enough?
- wp_new_comment requires author url and author email
- get_comments_number() vs. get_post_field( ‘comment_count’, ID )
- Where are comments coded when using custom theme?
- What is the point of get_comment_count() if you cannot limit by a comment type?
- Wrong IP address in comment section
- Comments turned off, but ‘Leave a reply’ link still there [duplicate]
- How to output number of comments with link to comments
- Get all comments associated with a specific page ID (comment_post_ID)
- How do I add custom field to Admin comment form and display
- I would like to count number of comments after 5 days ago
- Using Disqus with headless WordPress setup?
- Attaching author tag to the comment
- Removing(replacing) avtar in comments.php with some other HTML arrangements
- How to show a “Comments Are Closed” message on posts where comments have been closed?
- Necessary to have a comments.php if there are no comments?
- Inserting comments via a procedure
- Transfer comments from one domain to another
- WordPress is adding above html
- Passing user meta through comment form
- How do I separate author avatars and comments in 3.4.2?
- How do I convert users who put an email and username for a comment into registered users? [duplicate]
- Display DISQUS on homepage
- How to stop a specific person to comment on my blog? [closed]
- How do you fetch the authors email or IP from /comments? (REST API)
- WordPress Editor widgets “comments” and “post comments form” getting disappeared with elementor [closed]