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;
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.Β