wp_delete_user
Remove a user from a WordPress site, optionally reassigning their content to another user account for continuity.
Instructions
Deletes a user.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | The ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured. | |
| id | Yes | The ID of the user to delete. | |
| reassign | No | The ID of a user to reassign the deleted user's content to. |
Implementation Reference
- src/tools/users.ts:133-150 (registration)Registers the wp_delete_user tool within the UserTools.getTools() array, including name, description, parameters schema, and handler binding.{ name: "wp_delete_user", description: "Deletes a user.", parameters: [ { name: "id", type: "number", required: true, description: "The ID of the user to delete.", }, { name: "reassign", type: "number", description: "The ID of a user to reassign the deleted user's content to.", }, ], handler: this.handleDeleteUser.bind(this), },
- src/tools/users.ts:335-347 (handler)Implements the core logic for wp_delete_user: destructures id and optional reassign from params, calls WordPressClient.deleteUser, constructs success message (with reassign info if provided), handles errors.public async handleDeleteUser(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const { id, reassign } = params as { id: number; reassign?: number }; try { await client.deleteUser(id, reassign); let content = `✅ User ${id} has been deleted.`; if (reassign) { content += ` Their content has been reassigned to user ID ${reassign}.`; } return content; } catch (_error) { throw new Error(`Failed to delete user: ${getErrorMessage(_error)}`); } }
- src/tools/users.ts:136-148 (schema)Input schema definition for wp_delete_user tool: requires 'id' (number, user ID to delete), optional 'reassign' (number, ID for reassigning deleted user's content). Defines MCP tool parameters.parameters: [ { name: "id", type: "number", required: true, description: "The ID of the user to delete.", }, { name: "reassign", type: "number", description: "The ID of a user to reassign the deleted user's content to.", }, ],