Limited Support
Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.
Hi, I am referencing from the previous question posted. Link here:
The solution provided was the following filter shown below (link):
add_filter("wpdiscuz_user_role_can_comment", function ($canComment, $role) {
if ($role === "Paidplanrole") {
$canComment = true;
}
return $canComment;
}, 10, 2);
Like the user that previously posted, My users have a basic subscriber role for the free plan and then a new role for the paid plans. So every paying user gets 2 roles: subscriber and paidplanrole.
If I block subscriber roles from commenting, no one is able to comment because every user has subscriber auto set.
I tried adding the filter above to my functions.php and set the paidplanrole can comment.
It did not work at all. Anyone can comment whether or not they have paidplanrole.
I would like it to be only users that have paidplanrole assigned to them can comment.
Is this possible?
Thank you!
Hi,
Please try out this hook code:
add_filter('wpdiscuz_user_role_can_comment', function ($canComment) { $user = wp_get_current_user(); return in_array( 'Paidplanrole', (array) $user->roles); }, 11);