Prevent Post Authors from Moderating Comments in WordPress

When developing a complicated, role-based WordPress site for a client, I discovered an issue with the author role. By default authors do not have the moderate comment capability and we did not want them to for the site. However, they are quantitatively able to moderate comments on their own posts WordPress. This has brought lots of complaints to the WordPress bug tracker, however admins have said they will not fix for some reason. I discovered a fix courtesy of kevinB:

Index: capabilities.php
--- capabilities.php (revision 18607)
+++ capabilities.php (working copy)
@@ -1092,6 +1092,7 @@
                 $post_type_object = get_post_type_object( $post->post_type );
                 $caps = map_meta_cap( $post_type_object->cap->edit_post, $user_id, $post->ID );
+                $caps []= 'moderate_comments';
         case 'unfiltered_upload':
                 if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>