BP_REST_XProfile_Fields_Endpoint::bp_rest_get_field_visibility( BP_XProfile_Field $field_object )
Check current user can edit the visibility or not.
Description
Parameters
- $field_object
-
(Required) Field Object.
Return
(string)
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php
public function bp_rest_get_field_visibility( $field_object ) {
global $field;
// Get the field id into for user check.
$GLOBALS['profile_template'] = new stdClass();
$GLOBALS['profile_template']->in_the_loop = true;
// Setup current user id into global.
$field = $field_object;
return (
! bp_current_user_can( 'bp_xprofile_change_field_visibility' )
? 'disabled'
: (
(
! empty( $field->__get( 'allow_custom_visibility' ) )
&& 'allowed' === $field->__get( 'allow_custom_visibility' )
)
? $field->__get( 'allow_custom_visibility' )
: 'disabled'
)
);
}
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.