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.
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.Â
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.
@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.
Provide some testing user's (User A) login details that should be restricted to see the content of some pages
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.Â
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.
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.
We'll add a new hook in the next version, so you'll be able to get it to work as you like.Â
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.
We do all our best to release it ASAP. I'll update this topic once it's ready. Â
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.
@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.
The hook isn't added yet. It'll be available in the next version (no ETA yet). Â
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.
Here we also need the admin login details. Please send it to us again to info[at]gvectors.com email address.Â
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.
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.
@asti Great news, thanks. I'm trying to call this as part of another function, which currently runs inside the 'template_redirect' action, but it doesn't seem to be working. Can you confirm if this is possible? Below please find a shortened version of my code so you understand what I'm doing:
Â
add_action( 'template_redirect', 'pp_disable_access' );
function pp_disable_access($post_object) {
some code here to determine if comments should be hidden...
if ($pp_disable_view_comments == true) {
add_filter("wpdiscuz_load_form_and_comments", '__return_false', 10 ,3);
}
}
@asti PS - I also tried running it by copying and pasting it exactly as you have it in your documentation and it does not hide comments if you are not logged in. Let me know if you think I'm doing something wrong. Thanks.
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.