wpDiscuz 7 API Documentation

  1. Home
  2. Docs
  3. wpDiscuz 7 API Documentation
  4. Filters
  5. wpdiscuz_load_template
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

wpdiscuz_load_template

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

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);

Was this article helpful to you? Yes 2 No