Skip to content

feat: Add mutation support for user admin preferences fields #3561

Description

@izzygld

Description

The new user admin preference query fields added in #3551 (addressing #479) are read-only. The original issue also mentions supporting these fields in createUser and updateUser mutations.

This issue tracks adding mutation (write) support for the 4 user admin preference fields.

Fields to Support in Mutations

Field GraphQL Input Name Type WordPress Option Key Default
Admin Color adminColor String admin_color fresh
Rich Editing hasRichEditingEnabled Boolean rich_editing true
Syntax Highlighting hasSyntaxHighlightingEnabled Boolean syntax_highlighting true
Comment Shortcuts hasCommentShortcutsEnabled Boolean comment_shortcuts false

Example Mutation

mutation {
  updateUser(input: {
    id: "dXNlcjox"
    adminColor: "midnight"
    hasRichEditingEnabled: false
    hasSyntaxHighlightingEnabled: true
    hasCommentShortcutsEnabled: true
  }) {
    user {
      adminColor
      hasRichEditingEnabled
      hasSyntaxHighlightingEnabled
      hasCommentShortcutsEnabled
    }
  }
}

Implementation Notes

  • Input fields should be added to UserInput (for createUser) and UpdateUserInput (for updateUser)
  • Use update_user_option() to persist values (consistent with query resolution using get_user_option() per feat: add core user admin preferences fields to User type #3551)
  • Boolean inputs should be stored as WordPress string values ('true' / 'false')
  • adminColor could optionally validate against registered admin color schemes via wp_admin_css_color()
  • Permission checks should ensure only the user themselves or an admin can update these preferences

Acceptance Criteria

  • updateUser mutation accepts the 4 new input fields
  • createUser mutation accepts the 4 new input fields
  • Values persist correctly via update_user_option()
  • Boolean fields correctly convert GraphQL Boolean to WordPress string storage
  • Permission model respects existing updateUser capabilities
  • Unit tests cover: setting values, default behavior, permission checks
  • PHPCS and PHPStan pass

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions