Skip to main content
Glama

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
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe ID of the user to delete.
reassignNoThe ID of a user to reassign the deleted user's content to.

Implementation Reference

  • 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),
    },
  • 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)}`);
      }
    }
  • 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.",
      },
    ],

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/docdyhr/mcp-wordpress'

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