The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Can comment filter ...
 
Notifications
Clear all

[Solved] Can comment filter not working, help?

2 Posts
2 Users
0 Reactions
1,291 Views
(@beachcalsixaol-com)
Posts: 15
Eminent Member
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 
[#3859]

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!


 
Posted : 06/04/2022 12:26 am
Topic Tags
Asti
 Asti
(@asti)
Posts: 8267
Illustrious Member Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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

In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.

 
Posted : 07/04/2022 11:42 am