The logic of the hook is the same as the wpdiscuz_user_can_view_fields one. However, it works separately for each custom field. This means that using this hook, it’s possible to separately show or hide a specific field.
Changelog
since 7.6.20 version
Parameters
1. $canView – if true user can view the field
2. $currentUser – the current user
3. $fieldData- the current field’s data from settings
4. $fieldValue – the value of current field in the Database
Usage
add_filter("wpdiscuz_user_can_view_field", function ($canView, $currentUser, $fieldData, $fieldValue) { if (!empty($currentUser->roles) && is_array($currentUser->roles) && in_array('administrator', $currentUser->roles)) { if (isset($fieldData['name']) && $fieldData['name'] === 'Rating' && $fieldValue < 4) { $canView = false; } } return $canView; }, 10, 4);