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;
}
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.