wpDiscuz - WordPress Comment Plugin
Share:
Notifications
Clear all

Hiding Comments


aaronmckeon
Posts: 22
Topic starter
(@aaronmckeon)
Eminent Member
Joined: 1 month ago

I need to programmatically hide and disable comments on certain posts depending on a user's role.  However, the typical code for hiding comments is not working.  With wpDiscuz deactivated, the comments disappear.  With wpDiscuz, the code has no effect.  Can you suggest a better code that would eliminate comments entirely from a page?  This was run during the template_redirect action.

 

    $comments = array();
    return $comments;
12 Replies
Asti
Posts: 3860
 Asti
Support
(@asti)
Support member
Joined: 4 years ago

@aaronmckeon,

You can do it using the wpDiscuz options. 

First of all, you should create a new comment form and enable it for certain post IDs. The option calls Display comment form for post IDs. More info here: https://wpdiscuz.com/docs/wpdiscuz-7/getting-started/manage-comment-forms/comment-form-settings/#comment_form_for_post_id

In the next step, you should find the "Hide comment section for roles" section on the form add/edit section and select certain user roles. 

image
Reply
11 Replies
aaronmckeon
(@aaronmckeon)
Joined: 1 month ago

Eminent Member
Posts: 22

@asti Thanks for the quick reply, although unfortunately it's not quite that simple.  Some of our posts are categorized as premium (requiring a particular role) and some are not.  This is set by a custom taxonomy called "access-control".  I have a code snippet in place that contains all the logic, but the one piece I can't figure out is how to get rid of comments.

For example, one post may be set to "public" and another may be set to "tier-2" (requiring a tier-2 membership to the site).  If a user is logged in with an unpaid account and the post is set to require tier-2, the comments need to be hidden.  So, I'm hoping there is a line of code that would allow me to stop wpDiscuz for rendering on the page that I can then insert into my code snippet.

-- Aaron

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

Support member
Posts: 3860

@aaronmckeon,

Please provide us with the following information:

  1. Please send us the admin login details
  2. Provide some testing user's (User A) login details that should be restricted to see the content of some pages
  3. Provide us some example URL where the testing user (User A) should not see the content

Please send all those information to info[at]gvectors.com email address. I'll ask the developers to check the issue and provide some solutions for you if it's possible. 

Otherwise, they'll add a new hook in the next version of the wpDiscuz plugin. 

Reply
aaronmckeon
(@aaronmckeon)
Joined: 1 month ago

Eminent Member
Posts: 22

@asti Thanks - just sent the e-mail with all requested information.

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

Support member
Posts: 3860

ok, thank you. 

We'll check and back to you ASAP.  

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

Support member
Posts: 3860

We'll add a new hook in the next version, so you'll be able to get it to work as you like. 

Reply
aaronmckeon
(@aaronmckeon)
Joined: 1 month ago

Eminent Member
Posts: 22

@asti Excellent, thanks.  Can you tell me about how soon that would be?  I'm just trying to gauge if it'll be before my site is scheduled to go live.

 

- Aaron

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

Support member
Posts: 3860

@aaronmckeon,

We do all our best to release it ASAP. I'll update this topic once it's ready.  

Reply
aaronmckeon
(@aaronmckeon)
Joined: 1 month ago

Eminent Member
Posts: 22

@asti Just checking in on this.  I noticed an update get released and wasn't sure if this were included.  We are planning on going live this Friday and if this fix isn't in place we'll need to come up with a workaround.  Thanks for any updates.

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

Support member
Posts: 3860

@aaronmckeon,

The hook isn't added yet. It'll be available in the next version (no ETA yet).  

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

Support member
Posts: 3860

@aaronmckeon,

Here we also need the admin login details. Please send it to us again to info[at]gvectors.com email address. 

Reply
aaronmckeon
(@aaronmckeon)
Joined: 1 month ago

Eminent Member
Posts: 22

@asti Sent, thanks!

Reply
Share: