Can WordPress Authors Moderate Comments on Their Posts?

This week, a PublishPress customer wanted to understand the relationship between authors and comments their WordPress posts.

The customer wanted to know if authors could see manage comments on their own posts.

This tutorial is a guide to understanding the control that users have over comments on posts. You can also click this link if you want a guide to moderating comments in WordPress.

The Default Behavior for User Roles and Comments

To show how WordPress works, I've set up a test site with three posts. One of them is my post, as I'm using the “author” account. This user is in the “Author” user role. The other posts were written by different users. Each post has one comment.

In the screenshot below, I've clearly labeled the top post with the title, “This is my post”.

The Posts screen in WordPress
My Post

When I login as the author, I can automatically go to the “Comments” area of WordPress and see all the comments, even for posts I have not written.

Main WordPress comments screen
Comments All

However, there is one important difference for comments on my post. I can moderate comments on my post using these links: Unapprove / Reply / Quick Edit / Edit / Spam / Trash.

Comment moderation in WordPress
Comments Interacting

These settings will change depending on the user role:

  • Subscriber: Can not see or moderate any comments.
  • Contributor: Can see all comments, but can not moderate any comments.
  • Author: Can see all comments, but only moderate comments on their posts.
  • Editor: Can see and moderate all comments.
  • Administrator: Can see and moderate all comments.

How to Control Access to View and Moderate Comments

If you want to decide who can view and moderate comments, you need the PublishPress Capabilities plugin. On the “Capabilities” screen, you will be able to find the four capabilities that control comments:

  1. edit_posts: This controls access to the “Comments” screen.
  2. edit_others_posts
  3. edit_published_posts
  4. moderate_comments

In this screenshot below, you can see the edit_posts, edit_others_posts, and edit_published_posts capabilities:

edit_posts and edit_others_posts in WordPress

In this next screenshot, you can see moderate_comments capability:

The moderate_comments capability in WordPress

How to Hide Comments from Posts the Author Did Not Write

With some custom code, it is possible to customize which comments are visible on the “Comments” screen.

For example, you can hide comments for posts that the author didn't write. Add this code below to your theme's functions.php file:

function my_plugin_get_comment_list_by_user($clauses) {
        if (is_admin()) {
                global $user_ID, $wpdb;
                $clauses['join'] = ", ".$wpdb->base_prefix."posts";
                $clauses['where'] .= " AND ".$wpdb->base_prefix."posts.post_author = ".$user_ID." AND ".$wpdb->base_prefix."comments.comment_post_ID = ".$wpdb->base_prefix."posts.ID";
        return $clauses;

You can also extend this code so that Administrators and Editors (or anyone with the edit_others_posts) capability can still see all the comments.

if(!current_user_can('edit_others_posts')) {
add_filter('comments_clauses', 'my_plugin_get_comment_list_by_user');

This image below shows how the Comments screen looks after this final code change. The only flaw is that the number 3 does appear in the counters at the top of the screen. However, it's not possible to see the comments for anyone else's posts.

My Comments Only
My Comments Only

Allow Subscribers and Contributors to Manage Comments On their Posts

Using a combination of ideas in this post, it is possible to allow Subscribers and Contributors to manage comments on posts they have written.

Let's use the example of the “Contributor” role:

  • Use the PublishPress Capabilities plugin to give the “manage_comments” capability to the Contributor role. Also check that they have ethe dit_posts, edit_others_posts, and edit_published_posts capabilities.
  • Use the code sample mentioned in the previous section to hide the posts from other users.

How to Hide Specific Links on the Comments Screen

One other option for the “Comments” screen is to hide specific elements on the screen. This is the possible with the “Admin Features” option in PublishPress Capabilities Pro.

In this example, we're going to hide the “Unapprove” link for all comments. In this screenshot, we can see that the span name for the “Unapprove” link has the class of “unapprove”.

Find the CSS class on the WordPress comments screen
  • Go to the “Admin Features” screen.
  • Choose the user role you want to hide the “Unapprove” link for
  • Scroll down to the “Hide CSS Element” area.
  • Enter a “Label”.
  • Enter “unapprove” for the “Element IDs or Classes”.
Hiding the Unapprove link in WordPress
  • Now when you go back to the “Comments” screen, the “Unapprove” link will have vanished. You can repeat this process for other links and features on the “Comments” screen.
Hidden unapprove link in WordPress
  • Steve Burge

    Steve is the founder of PublishPress. He's been working with open source software for over 20 years. Originally from the UK, he now lives in Sarasota in the USA. This profile is generated by the PublishPress Authors plugin.

    View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *