Skip to main content
Glama

wp_get_current_user

Retrieve the currently authenticated WordPress user's profile, roles, capabilities, and account details to verify permissions and confirm identity.

Instructions

Retrieves the currently authenticated user with comprehensive profile information including roles, capabilities, and account details.

Usage Examples: • Get current user: wp_get_current_user • Check permissions: Use this to verify your current user's capabilities and roles • Account verification: Confirm you're authenticated with the correct account • Profile details: View registration date, email, and user metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.

Implementation Reference

  • The handler function that executes the wp_get_current_user tool logic. It fetches the current user from the WordPressClient, extracts and formats key details like roles, capabilities, registration date, and returns a formatted string with user profile information.
    public async handleGetCurrentUser( client: WordPressClient, params: Record<string, unknown>, ): Promise<Record<string, unknown>> { try { const user = await client.getCurrentUser(); const siteUrl = client.getSiteUrl(); // Extract meaningful information from capabilities const capabilities = user.capabilities || {}; const keyCapabilities = [ "edit_posts", "edit_pages", "publish_posts", "publish_pages", "delete_posts", "delete_pages", "manage_categories", "manage_options", "moderate_comments", "upload_files", "edit_others_posts", "delete_others_posts", ]; const userCapabilities = keyCapabilities.filter((cap) => capabilities[cap]).join(", "); const totalCapabilities = Object.keys(capabilities).length; // Format registration date more clearly const registrationDate = user.registered_date ? new Date(user.registered_date).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric", }) : "Not available"; // Extract role information const roles = user.roles || []; const primaryRole = roles[0] || "No role assigned"; const allRoles = roles.length > 1 ? roles.join(", ") : primaryRole; // Build comprehensive user information const content = `**Current User Details for ${siteUrl}**\n\n` + `- **ID:** ${user.id}\n` + `- **Display Name:** ${user.name || "Not set"}\n` + `- **Username:** ${user.slug || "Not set"}\n` + `- **Email:** ${user.email || "Not set"}\n` + `- **User URL:** ${user.url || "Not set"}\n` + `- **Nickname:** ${user.nickname || user.name || "Not set"}\n` + `- **Description:** ${user.description || "No description provided"}\n` + `- **Locale:** ${user.locale || "Default"}\n` + `- **Registration Date:** ${registrationDate}\n` + `- **Primary Role:** ${primaryRole}\n` + `- **All Roles:** ${allRoles}\n` + `- **Total Capabilities:** ${totalCapabilities} capabilities\n` + `- **Key Capabilities:** ${userCapabilities || "None"}\n` + `- **Profile Link:** ${user.link || `${siteUrl}/wp-admin/profile.php`}`; return { content }; } catch (_error) { throw new Error(`Failed to get current user: ${getErrorMessage(_error)}`); } }
  • The registration of the wp_get_current_user tool within the UserTools class's getTools() method, defining its name, description, empty parameters, and binding to the handleGetCurrentUser handler.
    { name: "wp_get_current_user", description: "Retrieves the currently authenticated user with comprehensive profile information including roles, capabilities, and account details.\n\n" + "**Usage Examples:**\n" + "• Get current user: `wp_get_current_user`\n" + "• Check permissions: Use this to verify your current user's capabilities and roles\n" + "• Account verification: Confirm you're authenticated with the correct account\n" + "• Profile details: View registration date, email, and user metadata", parameters: [], handler: this.handleGetCurrentUser.bind(this), },

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