Never Moderate Registered Users

plugin banner

Version: 2.0.4

Never moderate or mark as spam comments made by registered users, regardless of the apparent spamminess of the comment.

Author:Scott Reilly (profile at wordpress.org)
WordPress version required:3.1
WordPress version tested:5.5.3
Plugin version:2.3.1
Added to WordPress repository:13-09-2010
Last updated:29-08-2020
Rating, %:80
Rated by:2
Plugin URI:https://coffee2code.com/wp-plugins/never-mode...
Total downloads:6 997
Active installs:100+
plugin download
Click to start download

This plugin prevents comments from registered users from ever going into the moderation queue or getting automatically marked as spam, regardless of the apparent spamminess of the comment.

To be recognized as a registered user, the user must be logged into your site at the time they post their comment.

This plugin assumes that you trust your registered users. It will automatically approve any comment made by registered users, even if the comment stinks of spam. Therefore, it is recommended that you do not allow users to register themselves (uncheck the setting “Anyone can register” in the WordPress admin under Settings -> General).

You can still allow open registration, whereby these “subscribers” are moderated as usual, while other more privileged users do not get moderated. The plugin provides a filter, ‘c2c_never_moderate_registered_users_caps’, which allows you to specify the roles and capabilities that can bypass moderation. See the FAQ for an example.

This plugin is a partial successor to my now-defunct Never Moderate Admins or Post Author plugin. In addition to preventing admins and the post’s author from being moderated, that plugin also allowed you to prevent registered users from being moderated. WordPress has long since integrated that functionality, so the main thrust of that plugin became moot. However, the ability to never moderate registered users is still a valid need that requires this plugin.

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

Hooks

The plugin is further customizable via two filters. Typically, code making use of filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).

c2c_never_moderate_registered_users_caps (filter)

The ‘c2c_never_moderate_registered_users_caps’ filter allows you to define the capabilities that are automatically trusted, any one of which a user must have in order to never get moderated.

Arguments:

  • $caps (array): Array of capabilities, one of which a user must have in order to bypass moderation checks. Default is an empty array (meaning any registered user bypasses moderation checks.)

Example:

/**
 * Require that a user have at least 'contributor' capabilities in order to be
 * trusted enough not to be moderated.
 *
 * @param array $caps Array of trusted capabilities. If blank, then any user registered on the site is trusted.
 * @return array
 */
function dont_moderate_contributors( $caps ) {
    $caps[] = 'contributor';
    return $caps;
}
add_filter( 'c2c_never_moderate_registered_users_caps', 'dont_moderate_contributors' );

c2c_never_moderate_registered_users_approved (filter)

The ‘c2c_never_moderate_registered_users_approved’ filter allows for granular control for whether a comment by a registered user that would otherwise be moderated or marked as spam should automatically be approved. Note: this filter only runs when a comment is from a registered user and is flagged for moderation or spam.

Arguments:

  • $approved (int|string) The approval status. Will be 1 unless changed by another plugin using this hook. May be passed 1, 0, or ‘spam’. Hooking function can return any of those in addition to ‘trash’ or WP_Error.
  • $commentdata (array) Comment data.
  • $user (WP_User) The commenting user.

Example:

/**
 * Always moderate comments by registered users if they mention "Google".
 *
 * @param int|string $approved  Approval status. Will be one of 1, 0, or 'spam'.
 * @param array      $commentdata        Comment data.
 * @param WP_User    $user               The commenting user.
 * @return int|string|WP_Error Can a registered user's comment bypass moderation? Either 1, 0, 'spam', 'trash', or WP_Error.
 */
function c2c_even_registered_users_cannot_say_google( $approved, $commentdata, $user ) {
    if ( $approved && false !== stripos( $commentdata['comment_content'], 'google' ) ) {
        $approved = 0;
    }
    return $approved;
}
add_filter( 'c2c_never_moderate_registered_users_approved', 'c2c_even_registered_users_cannot_say_google', 10, 3 );

FAQ
ChangeLog