Paid Addons Support Forum Only

Please note, that here we only support Paid Addons issues and questions.

gVectors Support staff works from 6am to 6pm (GMT+0)

All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:

 

wpDiscuz Support Forum   wpForo Support Forum

[Solved] Comments must be private on 1 form/page only  


fmalgrand
Posts: 8
Customer
(@fmalgrand)
Member
Joined: 11 months ago

Hi there,

 

My site runs WpDiscuz and WpDiscuz private comments. I will be using it on a few pages across my site but there is 1 page where I need the comments to always be private. So I understand I can create various forms but I don't see the option to always make the comment private on that particular form or page. What would be the best way to go about it? Maybe a code snippet you can provide?

Thanks!!!!

Topic Tags
6 Replies
Astghik
Posts: 4125
Admin
(@astghik)
Support Team
Joined: 2 years ago

Hi @fmalgrand,

Thank you for using our products and for contacting us.

Please follow the steps below:

The last two options are located in Dashboard > Comments > Settings > Addons > Private Comments admin page.

PM settings
fmalgrand
Posts: 8
Customer
(@fmalgrand)
Member
Joined: 11 months ago

Thank you for your reply. It does work indeed for my form 2 but what if I want my form 1 to be allowed to pick private or public but not be automatically private ? 

Say that for form 1 I want to "Enable private threads for comment forms" but I don't want to "set new comments pivate"

But on my form 2 I want to "Enable private threads for comment forms" and "set new comments pivate".

See the problem is that the "Set new comment to private" cannot be applied to only 1 form.

Any further thoughts ?

Thanks

Macha

4 Replies
Astghik
Admin
(@astghik)
Joined: 2 years ago

Support Team
Posts: 4125

@fmalgrand

Please follow the steps below to get it resolved. 

1. Disable the "Set new comments to private" option.

2. Add the following code in the active theme's functions.php file:

add_action('wpdiscuz_front_scripts', function () {
   global $post;
   $wpdiscuz = wpDiscuz();
   $form = $wpdiscuz->wpdiscuzForm->getForm($post->ID);
   if ($form->getFormID() == X) {
       wp_enqueue_script('wpdiscuz-private-comments-set-private-by-default', get_stylesheet_directory_uri() . '/assets/js/wpdiscuz-private-comments-set-private-by-default.js', array('jquery'));
   }
});

The value X code should be change. Please set the Form ID you've created for the special (there all comments must be private) post/page instead of it.

On the screenshot below I've shown how to get the Form ID:

get form ID

3. Add the wpdiscuz-private-comments-set-private-by-default_js.js file into /wp-content/plugins/wpdiscuz-private-comments/assets/js folder. The file can be found in the zip folder below:

4. Edit the Form you've created, and fill the current post/pages IDs in the "Display comment form for post IDs" section. 

fmalgrand
Customer
(@fmalgrand)
Joined: 11 months ago

Member
Posts: 8

@astghik

Thank you, although it is not working. 

I disabled the set new comments to private.

I used my form id 11201.

I copied the code in the function.php of my child theme. 

I imported the js file with filezilla.

I added my page ID 1318

I am attaching pictures so you can see.

 

I can see the script is not being enqueued.

 

Thanks!

Screen Shot 2019 07 24 at 9.45.15 PM
Screen Shot 2019 07 24 at 9.44.54 PM
Screen Shot 2019 07 24 at 9.44.17 PM
Screen Shot 2019 07 24 at 9.43.39 PM
Screen Shot 2019 07 24 at 9.41.02 PM
Screen Shot 2019 07 24 at 9.39.20 AM
Screen Shot 2019 07 24 at 9.39.11 PM
Astghik
Admin
(@astghik)
Joined: 2 years ago

Support Team
Posts: 4125

@fmalgrand

First of all please uncheck the page post type. As you've filled the page D it's not necessary to check the post type. 

Form

3. Add the wpdiscuz-private-comments-set-private-by-default_js.js file into /wp-content/plugins/wpdiscuz-private-comments/assets/js folder. The file can be found in the zip folder below:

Sorry, I gave you the wrong path. The js file should be added in the active theme /assets/js/ folder.

fmalgrand
Customer
(@fmalgrand)
Joined: 11 months ago

Member
Posts: 8

@astghik

No worries! It works great now Smile Thanks very much for your patience and detailed answers Smile

Share: