Skip to main content
Glama

buddypress_add_group_member

Add a user to a BuddyPress group by specifying group ID, user ID, and optional member role (member, mod, admin) for community management.

Instructions

Add a member to a group

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_idYesGroup ID
roleNoMember role (member, mod, admin)
user_idYesUser ID

Implementation Reference

  • Handler that destructures input arguments (group_id, user_id, role) and makes a POST request to the BuddyPress REST API endpoint `/groups/{group_id}/members` with the user_id and optional role to add the member to the group.
    else if (name === 'buddypress_add_group_member') { const { group_id, user_id, role } = args as any; result = await buddypressRequest(`/groups/${group_id}/members`, 'POST', { user_id, role }); }
  • Input schema defining the parameters for the tool: required group_id and user_id (numbers), optional role (string).
    inputSchema: { type: 'object', properties: { group_id: { type: 'number', description: 'Group ID', required: true }, user_id: { type: 'number', description: 'User ID', required: true }, role: { type: 'string', description: 'Member role (member, mod, admin)' }, }, required: ['group_id', 'user_id'], },
  • src/index.ts:266-278 (registration)
    Tool object registration in the tools array, which is returned by ListToolsRequestSchema handler, including name, description, and schema.
    { name: 'buddypress_add_group_member', description: 'Add a member to a group', inputSchema: { type: 'object', properties: { group_id: { type: 'number', description: 'Group ID', required: true }, user_id: { type: 'number', description: 'User ID', required: true }, role: { type: 'string', description: 'Member role (member, mod, admin)' }, }, required: ['group_id', 'user_id'], }, },
  • Utility function that makes authenticated HTTP requests to the BuddyPress REST API using environment variables for URL and credentials.
    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(); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vapvarun/buddypress-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server