Skip to main content
Glama

wpnav_delete_user

Delete a WordPress user by ID and reassign their content to another user. Permanent deletion with audit logging for user management.

Instructions

Delete a WordPress user by ID. HIGH RISK: Permanent data loss. User content will be reassigned to specified user. Changes are logged in audit trail.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesWordPress user ID to delete
reassignYesUser ID to reassign deleted user's content to (required)
forceNoForce permanent deletion. Default: true

Implementation Reference

  • Executes the deletion of a WordPress user via WP REST API DELETE /wp/v2/users/{id} with reassign and force parameters. Includes validation, error handling for writes disabled, and structured response.
    handler: async (args, context) => { try { validateRequired(args, ['id', 'reassign']); const id = validateId(args.id, 'User'); const reassignId = validateId(args.reassign, 'Reassign User'); const params = new URLSearchParams({ force: String(args.force !== false), reassign: String(reassignId), }); const result = await context.wpRequest(`/wp/v2/users/${id}?${params.toString()}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, message: 'User deleted successfully', }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; const isWritesDisabled = errorMessage.includes('WRITES_DISABLED'); return { content: [{ type: 'text', text: JSON.stringify({ error: isWritesDisabled ? 'writes_disabled' : 'operation_failed', code: isWritesDisabled ? 'WRITES_DISABLED' : 'DELETE_FAILED', message: errorMessage, context: { resource_type: 'user', resource_id: args.id, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check user ID exists with wpnav_get_user', }, }, null, 2), }], isError: true, }; } },
  • Input schema validation for tool parameters: id (number, required), reassign (number, required), force (boolean, default true).
    inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress user ID to delete' }, reassign: { type: 'number', description: 'User ID to reassign deleted user\'s content to (required)' }, force: { type: 'boolean', description: 'Force permanent deletion. Default: true', default: true }, }, required: ['id', 'reassign'], },
  • Registers the wpnav_delete_user tool with toolRegistry, including definition (name, description, schema), handler, and category.
    toolRegistry.register({ definition: { name: 'wpnav_delete_user', description: 'Delete a WordPress user by ID. HIGH RISK: Permanent data loss. User content will be reassigned to specified user. Changes are logged in audit trail.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress user ID to delete' }, reassign: { type: 'number', description: 'User ID to reassign deleted user\'s content to (required)' }, force: { type: 'boolean', description: 'Force permanent deletion. Default: true', default: true }, }, required: ['id', 'reassign'], }, }, handler: async (args, context) => { try { validateRequired(args, ['id', 'reassign']); const id = validateId(args.id, 'User'); const reassignId = validateId(args.reassign, 'Reassign User'); const params = new URLSearchParams({ force: String(args.force !== false), reassign: String(reassignId), }); const result = await context.wpRequest(`/wp/v2/users/${id}?${params.toString()}`, { method: 'DELETE', }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ id: result.id, message: 'User deleted successfully', }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; const isWritesDisabled = errorMessage.includes('WRITES_DISABLED'); return { content: [{ type: 'text', text: JSON.stringify({ error: isWritesDisabled ? 'writes_disabled' : 'operation_failed', code: isWritesDisabled ? 'WRITES_DISABLED' : 'DELETE_FAILED', message: errorMessage, context: { resource_type: 'user', resource_id: args.id, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check user ID exists with wpnav_get_user', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.USERS, });

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/littlebearapps/wp-navigator-mcp'

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