Update User Metadata


Sets a custom usermeta key/value pair on a user, given their user ID, the meta_key, and the meta_value. Protected keys (capabilities, role level, session tokens) are refused. To remove a key, use mosmcp/delete-user-metadata.

Property Value
Ability slug mosmcp/update-user-metadata
Wire tool name mosmcp__update-user-metadata
Category Users & Roles (mosmcp-users)
Plan Free

 

Required access

Requirement Value
Capability edit_users
Minimum default role Administrator
Annotations readOnly: false · destructive: true · idempotent: true · openWorld: false

 

Input schema

Field Type Required Default Description
id integer (min 1) Yes — The user ID to update (required).
meta_key string Yes — The meta key to set (required). Protected keys are refused.
meta_value any Yes — The value to store (required).

 

Output schema

Field Type Required
id integer Yes
meta_key string Yes
updated boolean Yes

 

Example

Sample prompt
Save a 'membership_tier' value of 'gold' on user #42's profile.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 197,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__update-user-metadata",
    "arguments": {
      "input": {
        "id": 42,
        "meta_key": "membership_tier",
        "meta_value": "gold"
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 197,
  "result": {
    "isError": false,
    "structuredContent": {
      "id": 42,
      "meta_key": "membership_tier",
      "updated": true
    }
  }
}

 

Edge cases / errors

  • Protected meta_key (any capabilities, user_level or *session_tokens key, and a few other internal keys) → mosmcp_forbidden_meta_key, refused before anything is written.
  • meta_key is normalised with sanitize_key (lowercased, special characters stripped); an empty key → refused.
  • Overwrites any existing value(s) for the key; updated is true even if the value was unchanged.
  • No user with that id → mosmcp_user_not_found; no edit rights over that user → mosmcp_cannot_edit.

 


<< Previous Next >>
Send Password Reset Link Update User's Admin Locale

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.