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.