wpDiscuz 7 API Documentation

⌘K
  1. Home
  2. Docs
  3. wpDiscuz 7 API Documentat...
  4. Filters
  5. wpdiscuz_user_role_can_comment

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);