wpDiscuz 7 API Documentation

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

wpdiscuz_show_field_for_user

This filter can be used to control the visibility of the field based on the user/usergroup.

Changelog

since 7.4 version

Parameters

1. $isShowForUser – if the field should be visible or not. By default, it depends on the “Display for Guests” and “Display for Registered Users” options.
2. $currentUser – the object of the current user
3. $args – the parameters of the field. E.g. “Name”, “Description”, “Field is required”, etc.

Usage

add_filter('wpdiscuz_show_field_for_user', function($isShowForUser, $currentUser, $args){
    if($currentUser->exists() && in_array('contributor', $currentUser->roles) && $args['name'] == 'Field Name'){
        return false;
    }
    return $isShowForUser;
},15,3);

Was this article helpful to you? Yes 1 No