wpDiscuz 7 API Documentation

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

wpdiscuz_user_can_view_fields

If canview is set to false, the current user will not be able to view the custom field values.

Changelog

since 7.6.20 version

Parameters

1. $canView – if true the user can view fields ( globally )

2. $currentUser – the current user

Usage

add_filter("wpdiscuz_user_can_view_fields", function ($canView, $currentUser) {
    if (!empty($currentUser->roles) && is_array($currentUser->roles) && in_array('author', $currentUser->roles)) {
        $canView = false;
    }
    return $canView;
}, 10, 2);

Was this article helpful to you? Yes 1 No