wpDiscuz 7 API Documentation

  1. Home
  2. Docs
  3. wpDiscuz 7 API Documentation
  4. Filters
  5. wpdiscuz_user_role_can_comment
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

wpdiscuz_user_role_can_comment

This filter can be used for enabling or disabling commenting for specific user roles.

Changelog

Since 7.0.0 version

Parameters

1. $canComment (type: bool) – if the user with the current user role is able to comment or not
2. $role (type: string) – the current user role that should be allowed or disallowed to comment

Usage

add_filter("wpdiscuz_user_role_can_comment", function ($canComment, $role) {
    if ($role === "editor") {
        $canComment = true;
    }
    return $canComment;
}, 10, 2);

Was this article helpful to you? Yes No