Share:
Notifications
Clear all

Hide "Comment Form" and "Comment List"  


pyue6299
Posts: 48
(@pyue6299)
Eminent Member
Joined: 2 months ago

Hi there

 I would like to know is there a way to hide "Comment Form" and "Comment List" from a certain role of user?

I know we can restrict role certain to comment, but can we also do hiding?

Thanks

Patrick

10 Replies
pyue6299
Posts: 48
(@pyue6299)
Eminent Member
Joined: 2 months ago

I know you have an add-on "Private Comment" which gives my user an option to privatised their comment. But it only visable the privatised comment to Comment Author and Admin. Can this be also available to Post Author + Comment Author + Admin?

Reply
8 Replies
Asti
 Asti
Support
(@asti)
Joined: 3 years ago

Support member
Posts: 819

@pyue6299,

you can use the "Disable commenting for roles" option. More info here:  https://wpdiscuz.com/docs/wpdiscuz-7/getting-started/manage-comment-forms/comment-form-settings/#disable_commenting_for_roles

In this case, the comments will be visible for the roles, however, they'll not be able to post a comment. 

If you want to hide the whole comment section you should use additional code. 

Below is provided an example on how to hide comments for subscriber user role:

$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
comments_template();
}

The code should be added in the active theme functions.php file. 

Reply
amritmalhi64
(@amritmalhi64)
Joined: 2 days ago

New Member
Posts: 4

@asti Help Me comment bubble is not showing on my website 

Reply
pyue6299
(@pyue6299)
Joined: 2 months ago

Eminent Member
Posts: 48
Posted by: @pyue6299

I know you have an add-on "Private Comment" which gives my user an option to privatised their comment. But it only visable the privatised comment to Comment Author and Admin. Can this be also available to Post Author + Comment Author + Admin?

@Asti

How about this ? The "Private Comment" add-on is my perfect solution if the privatized comment can also be seen by Post Author.

Reply
Asti
 Asti
Support
(@asti)
Joined: 3 years ago

Support member
Posts: 819

@pyue6299,

There is the "Post author can moderate private comments threads" option. You should enable it. 

Reply
pyue6299
(@pyue6299)
Joined: 2 months ago

Eminent Member
Posts: 48

@asti

ok i will now activate back the add-on and try. Is there any way i can privatised all my comments by just one click?

Reply
pyue6299
(@pyue6299)
Joined: 2 months ago

Eminent Member
Posts: 48

@asti

No, it did not work. When i checked "Post Author" can moderate private comment, my post author does not see the privatised comment on frontend. And also, the disabled commenting role can also be commenting, such the post author.

I have created a staging site for your checking:

Site: https://jdclab.com/privatec

Admin: tim218

Password: Gl92Y!kkD*vF0PWaH9X%zlWw

Post URL: https://jdclab.com/privatec/?p=32168

Please Google translate the page if you can't read chinese, and press the middle login button just right after the post content.

Post author login: koil

Post author password: spurspur

Commenting user login: johnyip100

Commenting user password: spurspur

Also, the user role of "jdc" and "Post author" should not be allowed to commebt.

Thanks!

 

Reply
Asti
 Asti
Support
(@asti)
Joined: 3 years ago

Support member
Posts: 819

@pyue6299,

sorry for the late response. 

The code provided by me in this post should be added in the template files of the theme, not in the functions.php file. 

For example, in the single.php file, you'll need to find the comments_template(); function and replace it with the code I've provided. 

Reply
pyue6299
(@pyue6299)
Joined: 2 months ago

Eminent Member
Posts: 48

@asti

Thanks for your clarification, but i was talking about the  "Private Comment" add-on on my last reply. Thanks.

Reply
pyue6299
Posts: 48
(@pyue6299)
Eminent Member
Joined: 2 months ago

@asti

any update?

Reply
Share: