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

1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
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.