Toggle Side Panel
BuddyBoss Resources
  • Knowledge Base
    • All Articles
    • BuddyBoss Platform
    • BuddyBoss Theme
    • BuddyBoss App
    • Integrations
    • Advanced Setup
    • Troubleshooting
    • Release Notes
      • BuddyBoss Platform
      • BuddyBoss Platform Pro
      • BuddyBoss Theme
      • BuddyBoss App
      • BuddyBoss App Plugin
      • Other Products
  • Developers
    • Developer Tutorials
      • Web Development
      • App Development
    • Code Reference
      • Functions
      • Hooks
      • Classes
      • Methods
      • Commands
      • App Codex
    • REST API
      • BuddyBoss Platform
      • BuddyBoss App
    • Font Cheatsheet
    • Github Project
  • Roadmap
  • Go to BuddyBoss
More options
    Contact Support
    Filter
    • Knowledge Base
      • All Articles
      • BuddyBoss Platform
      • BuddyBoss Theme
      • BuddyBoss App
      • Integrations
      • Advanced Setup
      • Troubleshooting
      • Release Notes
        • BuddyBoss Platform
        • BuddyBoss Platform Pro
        • BuddyBoss Theme
        • BuddyBoss App
        • BuddyBoss App Plugin
        • Other Products
    • Developers
      • Developer Tutorials
        • Web Development
        • App Development
      • Code Reference
        • Functions
        • Hooks
        • Classes
        • Methods
        • Commands
        • App Codex
      • REST API
        • BuddyBoss Platform
        • BuddyBoss App
      • Font Cheatsheet
      • Github Project
    • Roadmap
    • Go to BuddyBoss
    Filter
    Close search
    Filter

    Contents

    • Description
    • Parameters
    • Return
    • Source
    • Related
    Code Reference Classes BP_REST_Account_Settings_Options_Endpoint BP_REST_Account_Settings_Options_Endpoint::bp_rest_get_xprofile_field_visibility()

    BP_REST_Account_Settings_Options_Endpoint::bp_rest_get_xprofile_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-settings/classes/class-bp-rest-account-settings-options-endpoint.php

    	public function bp_rest_get_xprofile_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'
    		)
    		);
    	}
    

    Expand full source code Collapse full source code

    Related

    Uses

    Uses
    Uses Description
    bp-core/bp-core-caps.php: bp_current_user_can()

    Check whether the current user has a given capability.

    Used By
    Used By Description
    bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php: BP_REST_Account_Settings_Options_Endpoint::get_profile_fields()

    Get Fields for the Profile “Privacy”.

    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.

    © 2025 • BuddyBoss