Profile Field

Schema

The schema defines all the fields that exist for a profile field object.

id

integer
A unique numeric ID for the profile field.
Read only
Context: viewedit
group_id

integer
The ID of the group the profile field is part of.
Context: view, edit
parent_id

integer
The ID of the parent field.
Context: view, edit
type

string
The form element used by the profile field.
Context: view, edit
One of: checkbox, datebox, multiselectbox, number, url, radio, selectbox, textarea, textbox, telephone, option (1)
name

string
The name of the profile field.
Context: view, edit
description

object
The raw and rendered descriptions of the profile field.
Context: viewedit
is_required

boolean
Whether the profile field must have a value or not.
Context: viewedit
can_delete

boolean
Whether the profile field can be deleted or not.
Default: true
Context: viewedit
field_order

integer
The order of the profile field within the group of profile fields.
Context: viewedit
option_order

integer
The order of the option within the profile field’s list of options.
Context: viewedit
order_by

string
How the options of a profile field are sorted.
Context: viewedit
Default: asc
One of: asc, desc
is_default_option

boolean
Whether the option is the default one for the profile field.
Context: viewedit
visibility_level

string
Who may see the saved value for this profile field.
Context: viewedit
Default: public
One of: public, adminsonly, loggedin, friends (1)
options
array
Options of the profile field.
Read only.
Context: view, edit
data

object
The raw, unserialized and rendered values for this profile field.
Context: viewedit
More details about the value object.

(1) This is the list of BuddyPress built-in Profile field types. Please note that BuddyPress plugins can extend this list.

(2) The friends visibility level is only available when the Friend Connections component is active.

Top ↑

List profile fields

Top ↑

Arguments

NameTypeDescription
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of: view, edit
pageintegerCurrent page of the collection.
Default: 1
per_pageintegerMaximum number of profile fields to be returned in the result set.
Default: 10
searchstringLimit results to those matching a string.
profile_group_idintegerID of the profile group that has profile fields.
hide_empty_groupsbooleanWhether to hide profile groups that do not have any profile fields or not.
Default: false
user_idintegerRequired if you want to load a specific user’s data.
Default: the logged in user ID.
member_typearrayLimit profile fields to those restricted to a given member type, or array of member types. If the $user_id is provided, then the value of $member_type will be overridden by the member types of that user. The special value of ‘any’ will return only those fields that are unrestricted by member type – i.e., those applicable to any type.
Default: []
hide_empty_fieldsbooleanWhether to hide profile fields where the user has not provided data or not.
Default: false
fetch_field_databooleanWhether to fetch data for each profile field. Requires a $user_id.
Default: false
fetch_visibility_levelbooleanWhether to fetch the visibility level for each field.
Default: false
signup_fields_onlybooleanWhether to only return signup fields.
Default: false
exclude_groupsarrayEnsure result set excludes specific profile field groups.
Default: []
exclude_fieldsarrayEnsure result set excludes specific profile fields.
Default: []
update_meta_cachebooleanWhether to pre-fetch xprofilemeta for all retrieved groups, fields, and data.
Default: true

Top ↑

Definition

GET /buddypress/v1/xprofile/fields

Top ↑

Example of use

Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.
bp.apiRequest( {
  path: 'buddypress/v1/xprofile/fields',
  type: 'GET',
  data: {
    context: 'view'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Create a profile field

Top ↑

Arguments

NameTypeDescription
group_idintegerThe ID of the group the field is part of.
Required
parent_idintegerThe ID of the parent field.
typestringThe form element of the profile field.
Required
One of: checkbox, datebox, multiselectbox, number, url, radio, selectbox, textarea, textbox, telephone, option
namestringThe name of the profile field.
Required
descriptionstringThe description of the profile field.
is_requiredbooleanWhether the profile field must have a value.
can_deletebooleanWhether the profile field can be deleted or not.
Default: true
field_orderintegerThe order of the profile field within the group of profile fields.
option_orderintegerThe order of the option within the profile field’s list of options.
order_bystringHow the options of a profile field are sorted.
Default: asc
One of: asc, desc
is_default_optionbooleanWhether the option is the default one for the profile field.
default_visibilitystringDefault visibility for the profile field.
Default: public
One of: public, adminsonly, loggedin, friends
allow_custom_visibilitystringWhether to allow members to set the visibility for the profile field data or not.
Default: allowed
One of: allowed, disabled
do_autolinkstringAutolink status for this profile field.
Default: off
One of: on, off

Top ↑

Definition

POST /buddypress/v1/xprofile/fields

Top ↑

Example of use

Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.

bp.apiRequest( {
  path: 'buddypress/v1/xprofile/fields',
  type: 'POST',
  data: {
    context: 'edit',
    group_id: 2,                    // Required
    type: 'textbox',                // Required
    name: 'BuddyPress.org username' // Required
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Retrieve a specific profile field

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the profile field.
Required
user_idintegerRequired if you want to load a specific user’s data.
Default: 0
fetch_field_databooleanWhether to fetch data for the field. Requires $user_id.
Default: false

Top ↑

Definition

GET /buddypress/v1/xprofile/fields/<id>

Top ↑

Example of use

Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.

bp.apiRequest( {
  path: 'buddypress/v1/xprofile/fields/5',
  type: 'GET',
  data: {
    context: 'view'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Update a specific profile field

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the profile field.
Required
group_idintegerThe ID of the profile group the profile field is part of.
parent_idintegerThe ID of the parent profile field.
typestringThe form element used by the profile field.
One of: checkbox, datebox, multiselectbox, number, url, radio, selectbox, textarea, textbox, telephone, option
namestringThe name of the profile field.
descriptionstringThe description of the profile field.
is_requiredbooleanWhether the profile field must have a value.
can_deletebooleanWhether the profile field can be deleted or not.
Default: true
field_orderintegerThe order of the profile field within the group of profile fields.
option_orderintegerThe order of the option within the profile field’s list of options.
order_bystringHow the options of a profile field are sorted.
Default: asc
One of: asc, desc
is_default_optionbooleanWhether the option is the default one for the profile field.
default_visibilitystringDefault visibility for the profile field.
Default: public
One of: public, adminsonly, loggedin, friends
allow_custom_visibilitystringWhether to allow members to set the visibility for the profile field data or not.
Default: allowed
One of: allowed, disabled
do_autolinkstringAutolink status for this profile field.
Default: off
One of: : on, off

Top ↑

Definition

PUT /buddypress/v1/xprofile/fields/<id>

Top ↑

Example of use

Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.

bp.apiRequest( {
  path: 'buddypress/v1/xprofile/fields/5',
  type: 'PUT',
  data: {
    context: 'edit',
    description: 'The username you used to register on BuddyPress.org'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Delete a specific profile field

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the profile field.
Required
delete_databooleanRequired if you want to delete users data for the field.
Default: false

Top ↑

Definition

DELETE /buddypress/v1/xprofile/fields/<id>

Top ↑

Example of use

Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.

bp.apiRequest( {
  path: 'buddypress/v1/xprofile/fields/5',
  type: 'DELETE',
  data {
    context: 'edit',
    delete_data: true
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );