Skip to content

feat: add core user admin preferences fields to User type#3551

Merged
jasonbahl merged 2 commits into
wp-graphql:developfrom
izzygld:feat/user-admin-preferences-fields-v2
Feb 10, 2026
Merged

feat: add core user admin preferences fields to User type#3551
jasonbahl merged 2 commits into
wp-graphql:developfrom
izzygld:feat/user-admin-preferences-fields-v2

Conversation

@izzygld

@izzygld izzygld commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Addresses Issue #479

This adds the following fields to the User type that were previously missing
from the core WordPress user meta:

- adminColor: The admin color scheme preference (fresh, midnight, etc.)
- hasRichEditingEnabled: Whether the visual editor is enabled
- hasSyntaxHighlightingEnabled: Whether code syntax highlighting is enabled
- hasCommentShortcutsEnabled: Whether comment moderation shortcuts are enabled

These fields follow the declarative naming convention suggested in wp-graphql#479.

Closes wp-graphql#479
@codecov

codecov Bot commented Feb 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.65%. Comparing base (4f0f2b1) to head (b1a603d).
⚠️ Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
src/Model/User.php 93.33% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3551      +/-   ##
=============================================
+ Coverage      83.63%   83.65%   +0.02%     
- Complexity      4209     4216       +7     
=============================================
  Files            217      217              
  Lines          18756    18802      +46     
=============================================
+ Hits           15686    15729      +43     
- Misses          3070     3073       +3     
Flag Coverage Δ
multisite 83.65% <96.66%> (+0.02%) ⬆️
single 83.65% <96.66%> (+0.02%) ⬆️
twentytwentyfive 83.61% <96.66%> (+0.02%) ⬆️
twentytwentyone 83.61% <96.66%> (+0.02%) ⬆️
wpunit 83.65% <96.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/Type/ObjectType/User.php 99.16% <100.00%> (+0.09%) ⬆️
src/Model/User.php 98.08% <93.33%> (-1.92%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jasonbahl jasonbahl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

It addresses the core issue described in #479 and adds the core user admin preference fields to the User type.

Similar to our discussion about options, I'd love at some point to have a more formal way to map registered user options to the schema more programmatically (i.e. when a plugin adds fields to the user profile, I'd love for those fields to automatically map to the schema), but until we spend the time to come up with a centralized registry/map, this is a good step.

I like that you followed the existing patterns using the Model layer and added tests! 🙌

I made a few changes, but wanted to see what you think:

  • Switched from get_user_meta() to get_user_option() for all four fields:
    Better alignment with WordPress core (especially multisite)
    get_user_option() handles site-specific user options correctly

  • Updated default handling since get_user_option() returns false when not set

  • Added edge case tests:

    • testUserAdminPreferencesExplicitFalseValues(): Verifies explicit 'false' string values are handled correctly
    • testUserAdminPreferencesFieldVisibility(): Tests visibility rules across different user roles (admin, subscriber, public)
  • Updated existing tests to use update_user_option() for consistency with the new implementation

Note: Mutation support for these fields (mentioned in the original issue) can be tracked in a follow-up issue.

@izzygld izzygld left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreicate the thorugh review and improvments, Jason — super helpful. The switch to get_user_option() totally makes sense, I def didnt think thru multisite behaviour properly there.

And the edge case tests around explicit 'false' strings + cross-role visibility are spot on — exactly the kinda coverage I should of had from the start. Good lesson learned.

I’ll open a follow up issue for mutation support. Also the idea of a centralized registry mapping user options to the schema is really intresting — feels like a nice clean way for plugins to expose user profile fields automatically. Happy to take a crack at an RFC for that if thats somthing you’d wanna see.

@jasonbahl jasonbahl merged commit 7d41099 into wp-graphql:develop Feb 10, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants