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:

Filter by custom fields

Topic prefix

AI Assistant
Disable Comment For...
 
Notifications
Clear all

[Solved] Disable Comment Form

3 Posts
2 Users
0 Reactions
1,364 Views
(@aaronmckeon)
Posts: 47
Trusted 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
 
[#4647]

I built the following code using another forum discussion.  However, the original code was developed so that the reply form would still be visible.  Can anybody tell me how to modify the code so that it also hides the reply comment form?  I want this code to eliminate ALL commenting for users that meet the specified criteria.  Thanks for any help.

add_filter('wpdiscuz_form_render', 'pp_hide_comment_form', 10, 3);
function pp_hide_comment_form($output, $commentsCount, $currentUser) {

// specify list of tags that trigger loss of commenting privileges
$disallowed_tags = array('Email-Status-invalid', 'Email-Status-spamtrap', 'Email-Status-do_not_mail');

// hide the comment form if user has a disallowed tag
if (!empty($currentUser->ID) && wpf_has_tag($disallowed_tags)) {
$output = preg_replace('~<div class="wpd-form[^"\']+wpd-main-form-wrapper[^>]+>.*?(<div id="wpdiscuz_hidden_secondary_form")~is', '$1', $output);
}

return $output;

}

Original thread for reference: https://wpdiscuz.com/community/troubleshooting/disable-main-form-only-allow-reply/#post-10130


 
Posted : 04/08/2022 7:03 pm
(@aaronmckeon)
Posts: 47
Trusted 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
 

Follow-up: I was able to fix this by simply changing the $ouput to an alert message that informs the user their commenting ability has been disabled.


 
Posted : 04/08/2022 7:37 pm
Asti
 Asti
(@asti)
Posts: 8257
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
 

@aaronmckeon,

Thank you for letting us know. Glad to hear that the issue is solved. 

We're going to mark this thread as resolved. Feel free to open a new topic if you have further questions.


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 : 05/08/2022 12:26 pm