Plugin / Always Allow Admin Comments

Scott Reilly

Description

Description

This plugin enables a user with the administrator role the ability to comment on any post or page, even if the comments for that post or page are closed. When the plugin is active, this behavior is automatically enabled.

Administrators can be explicitly prevented from commenting on specific posts via two approaches:

  • When creating or editing a post, in the “Prevent Admin Comments” metabox (in the block editor) or the “Discussion” metabox (in the classic editor) there is a checkbox labeled “Prevent administrators from commenting” that only administrators can access. Checking the checkbox will prevent administrators from commenting on the post even though this plugin is active. (If the metabox isn’t visible for you when using the classic editor, then expand the “Screen Options” slide-down panel on the upper-right of the page.)
  • Programmatically, via the use of the ‘c2c_admin_can_always_comment_disable’ filter. This can be used be provide more fine-grained access control and contextual handling. See the “Hooks” section for documentation on the filter’s use.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Hooks

The plugin is further customizable via one hook. Such code should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).

c2c_always_allow_admin_comments_disable (filter)

The ‘c2c_always_allow_admin_comments_disable’ filter allows you to customize whether comments should actually be disabled for a particular admin user. By default, all admin users can always comment on posts and pages. Using this filter, you have finer-grained controls to override this behavior. It takes into account the checkbox provided per post to explicitly prevent admin comments.

NOTE: This filter is only used if comments for the post are closed and the current user is an admin. This filter is only to override the behavior of the plugin and is not a general purpose filter for enabling or disabling comments.

Arguments:

  • $status (bool): The comment status of the current post for the current user.
  • $post_id (int): The ID of the post whose comments are being checked.

Return:

  • (bool): True if admin commenting is disabled, false if admin can comment.

Example:

/**
 * Only allow certain admins the ability to comment on all posts.
 *
 * @param  bool $status  The comment open status.
 * @param  int  $post_id The post id.
 * @return bool True if admin commenting is disabled, false if not.
 */
function restrict_admin_commenting( $status, $post_id ) {
    // User IDs of the admins who can always comment.
    $admins_who_can_comment = array( 2, 13 );

    // Admins not specified above cannot comment when comments are closed.
    return ! in_array( get_current_user_id(), $admins_who_can_comment );
}
add_filter( 'c2c_always_allow_admin_comments_disable', 'restrict_admin_commenting', 10, 2 );

Ratings

0
0 reviews

Rating breakdown

Details Information

Version

1.2.1

First Released

10 Mar, 2016

Total Downloads

787

Wordpress Version

4.6 or higher

Tested up to:

5.2.4

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.