buddypress_get_xprofile_data
Retrieve extended profile data for specific users and fields in BuddyPress community sites. Use this tool to access user profile information programmatically through the REST API.
Instructions
Get XProfile data for a specific user and field
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| field_id | Yes | Field ID | |
| user_id | Yes | User ID |
Implementation Reference
- src/index.ts:338-349 (registration)Registration of the buddypress_get_xprofile_data tool including its schema definition with input parameters field_id and user_id.{ name: 'buddypress_get_xprofile_data', description: 'Get XProfile data for a specific user and field', inputSchema: { type: 'object', properties: { field_id: { type: 'number', description: 'Field ID', required: true }, user_id: { type: 'number', description: 'User ID', required: true }, }, required: ['field_id', 'user_id'], }, },
- src/index.ts:662-664 (handler)Handler implementation for the buddypress_get_xprofile_data tool. It constructs the BuddyPress REST API endpoint `/xprofile/{field_id}/data/{user_id}` and calls the shared buddypressRequest helper to fetch the XProfile data.else if (name === 'buddypress_get_xprofile_data') { result = await buddypressRequest(`/xprofile/${args.field_id}/data/${args.user_id}`); }
- src/index.ts:18-46 (helper)Shared helper function used by all BuddyPress tools, including buddypress_get_xprofile_data, to make authenticated HTTP 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(); }