buddypress_get_xprofile_field
Retrieve specific extended profile field data from BuddyPress sites using field ID to access member profile information and custom field values.
Instructions
Get a single XProfile field
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fetch_field_data | No | Include field data | |
| id | Yes | Field ID |
Implementation Reference
- src/index.ts:657-660 (handler)Handler logic for the buddypress_get_xprofile_field tool. Parses arguments, builds query parameters, and calls the BuddyPress API endpoint /xprofile/fields/{id}.else if (name === 'buddypress_get_xprofile_field') { const params = new URLSearchParams(); if (args.fetch_field_data !== undefined) params.append('fetch_field_data', String(args.fetch_field_data)); result = await buddypressRequest(`/xprofile/fields/${args.id}?${params}`);
- src/index.ts:326-337 (registration)Tool registration in the tools array, including name, description, and input schema. Used by ListToolsRequestHandler.{ name: 'buddypress_get_xprofile_field', description: 'Get a single XProfile field', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Field ID', required: true }, fetch_field_data: { type: 'boolean', description: 'Include field data' }, }, required: ['id'], }, },
- src/index.ts:329-336 (schema)Input schema definition for validating tool arguments: requires 'id' (number), optional 'fetch_field_data' (boolean).inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Field ID', required: true }, fetch_field_data: { type: 'boolean', description: 'Include field data' }, }, required: ['id'], },
- src/index.ts:18-46 (helper)Shared helper function used by all BuddyPress tools, including this one, to make authenticated API requests to the BuddyPress REST API.async function buddypressRequest( endpoint: string, method: string = 'GET', body?: any ): Promise<any> { const url = `${BUDDYPRESS_URL}/wp-json/buddypress/v2${endpoint}`; const auth = Buffer.from(`${BUDDYPRESS_USERNAME}:${BUDDYPRESS_PASSWORD}`).toString('base64'); const options: any = { method, headers: { 'Authorization': `Basic ${auth}`, 'Content-Type': 'application/json', }, }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`BuddyPress API Error (${response.status}): ${errorText}`); } return await response.json(); }