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 main form, ...
 
Notifications
Clear all

[Solved] Disable main form, only allow reply

8 Posts
2 Users
2 Reactions
3,049 Views
(@zoker)
Posts: 22
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
 
[#2690]

Hi there,

 

I try to disable the comment field, if the user has already commented on this post. But he should be able to reply to his own comment and other comments.

When I disable the form with this filter ...

function hide_form($output, $commentsCount, $currentUser) {
    return '';
}
add_filter('wpdiscuz_form_render', 'hide_form', 10, 3);

... the form is disabled, but also the reply form. 

Is there any way to do this? 

 

If I have a function to disable the main form, I will surround it with a check if the user has already made a comment. But I first need the form disable filter.

Thanks!


 
Posted : 05/08/2021 1:49 am
(@zoker)
Posts: 22
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
 

For everyone interested, here is the code to get if the current user already posted a level 0 comment:

global $post;
$args = array(
    'post_id'    => $post->ID,
    'author__in' => get_current_user_id(),
    'parent' => 0,
    'count' => true
);
$comments_count = get_comments( $args );

 
Posted : 05/08/2021 2:04 am
(@zoker)
Posts: 22
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
 

This is not the solution, this is only the wrapper I need for getting, if a user already made a level 0 comment on the post. I still need the function, that removes the main comment form, but not the reply form. 


 
Posted : 05/08/2021 1:57 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
 

Hi Zoker,

I'm going to ask the developers if there is a simple solution for this and back to you asap. 


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/2021 6:28 pm
Zoker reacted
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
 

@zoker,

Please try this one: 

function hide_form($output, $commentsCount, $currentUser) {
   global $post;
   $args = array(
      'post_id'    => $post->ID,
      'author__in' => get_current_user_id(),
      'parent' => 0,
      'count' => true
   );
   $comments_count = get_comments( $args );
    if ($comments_count) {
        $output = preg_replace('~<div class="wpd-form[^"\']+wpd-main-form-wrapper[^>]+>.*?(<div id="wpdiscuz_hidden_secondary_form")~is', '$1', $output);
    }
   return $output;
}
add_filter('wpdiscuz_form_render', 'hide_form', 10, 3);

It should work fine. 


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 : 06/08/2021 12:50 pm
(@zoker)
Posts: 22
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
 

@asti Yes that works, thank you very much! Can you please ask the developers to include a proper filter for that anyway? Would be a cleaner way instead of using a pre_replace with regex (especially if the html changes within a update, then the regex won't work anymore) 🙂

But for now this is perfect, thanks!


 
Posted : 06/08/2021 1:42 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
 

Zoker,

I'm really sorry, but this is not planned yet.

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


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 : 06/08/2021 4:39 pm
(@zoker)
Posts: 22
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
 

@asti Yes, that's why I asked you to create a feature request for this 🙂

Thanks!

Will do, thanks!


 
Posted : 07/08/2021 2:35 pm
Asti reacted