• 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
    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
    Filter

    Contents

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

    BP_REST_Account_Settings_Options_Endpoint::get_profile_fields()

    Get Fields for the Profile “Privacy”.

    Description

    • From: ‘members/single/settings/profile’

    Return

    (array|mixed|void)

    Source

    File: bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php

    	public function get_profile_fields() {
    		$fields       = array();
    		$field_groups = bp_xprofile_get_groups(
    			array(
    				'fetch_fields'           => true,
    				'fetch_field_data'       => true,
    				'fetch_visibility_level' => true,
    			)
    		);
    
    		if ( ! empty( $field_groups ) ) {
    			foreach ( $field_groups as $group ) {
    				$fields[] = array(
    					'name'        => '',
    					'label'       => '',
    					'field'       => '',
    					'value'       => '',
    					'options'     => array(),
    					'group_label' => $group->name,
    				);
    
    				if ( isset( $group->fields ) && ! empty( $group->fields ) ) {
    					foreach ( $group->fields as $field ) {
    						$fields[] = array(
    							'name'        => 'field_' . $field->id,
    							'label'       => $field->name,
    							'field'       => ( ! empty( $field->__get( 'allow_custom_visibility' ) ) && 'allowed' === $field->__get( 'allow_custom_visibility' ) ) ? 'select' : '',
    							'value'       => xprofile_get_field_visibility_level( $field->id, bp_loggedin_user_id() ),
    							'options'     => array_column( bp_xprofile_get_visibility_levels(), 'label', 'id' ),
    							'group_label' => '',
    						);
    					}
    				}
    			}
    		}
    
    		return $fields;
    	}
    

    Expand full source code Collapse full source code

    Related

    Uses

    Uses
    Uses Description
    bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php: BP_REST_Account_Settings_Options_Endpoint::bp_rest_get_xprofile_field_visibility()

    Check current user can edit the visibility or not.

    bp-core/bp-core-functions.php: bp_core_hide_display_name_field()

    Whether or not profile field is hidden.

    bp-xprofile/bp-xprofile-functions.php: bp_xprofile_get_visibility_levels()

    Get visibility levels out of the $bp global.

    bp-xprofile/bp-xprofile-functions.php: xprofile_get_field_visibility_level()

    Get the visibility level for a field.

    bp-xprofile/bp-xprofile-functions.php: bp_xprofile_get_groups()

    Fetch a set of field groups, populated with fields and field data.

    bp-core/bp-core-template.php: bp_loggedin_user_id()

    Get the ID of the currently logged-in user.

    Show 1 more use Hide more uses

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

    Retrieve Account Settings options.

    bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php: BP_REST_Account_Settings_Options_Endpoint::update_item()

    Update Account Settings options.

    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.

    © 2023 • BuddyBoss