This filter can be used for detecting if the wpDiscuz form u comments should be loaded or not.
Changelog
Since 7.3.9 version
Parameters
1. $load (type: bool) – if the comments should be loaded or not
2. $user (type: WP_User object) - the object of the current user
3. $post (type: WP_Post object) – the object of the current post
2. $user (type: WP_User object) - the object of the current user
3. $post (type: WP_Post object) – the object of the current post
Usage
add_filter("wpdiscuz_load_template", function ($load, $user, $post) {
if (empty($user->ID)) { // not logged in user >>> do not load wpdiscuz form and comments
$load = false;
} else {
// user logged in and user role is subscriber >>> do not load wpdiscuz form and comment
if (!empty($user->roles) && is_array($user->roles) && in_array("subscriber", $user->roles)) {
$load = false;
}
}
return $load;
}, 10, 3);