Skip to content

Abilities API: Return the core/users-query registration date as registered.site and registered.gmt - #15001

Closed
jorgefilipecosta wants to merge 2 commits into
WordPress:trunkfrom
jorgefilipecosta:update/users-query-registered-dates
Closed

jorgefilipecosta wants to merge 2 commits into
WordPress:trunkfrom
jorgefilipecosta:update/users-query-registered-dates

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Related: #15000

This PR replaces the registered_date field of core/users-query with a registered object, like the core/content-query date fields:

  • registered returns { site, gmt }: the registration date in the site's timezone and in GMT. Each is null when the stored date is not a valid date.
  • The fields input accepts registered.site and registered.gmt to select a single date.
  • Visibility is unchanged: only for the user themselves or users the caller can edit.
  • Tests updated, plus coverage for site timezones and offsets, sub-field selection, out-of-range dates and visibility.

Trac ticket: https://core.trac.wordpress.org/ticket/64657

Testing

Verify unit tests are passing:

vendor/bin/phpunit tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php

Or run the ability in the editor console:

wp.apiFetch( { path: wp.url.addQueryArgs( '/wp-abilities/v1/abilities/core/users-query/run', { input: { fields: [ 'id', 'registered' ] } } ) } );

Each item should have a registered object with site and gmt keys.

AI disclosure: the change and tests were drafted with AI assistance (Claude Code) and reviewed by me.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jorgefilipecosta, gziolo.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

public static function data_unknown_requested_fields(): array {
return array(
'unknown field' => array( 'bogus_field' ),
'removed registered_date field' => array( 'registered_date' ),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's not keep the history of this removed field, since it didn't become part of the public contract.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, the registered_date row was removed.

@gziolo gziolo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, this looks great! The new registered object uses the same { site, gmt } shape and the same field path handling as the date fields in core/content-query. That keeps the two abilities aligned, and clients can handle dates the same way in both.

I also like the improved date handling. user_registered is now always read as UTC, and it no longer depends on the PHP default timezone. The formatter preserves null handling for zero dates and handles timezone conversions that push dates outside the supported four-digit year range. The strict false check also correctly preserves the Unix epoch. The tests for DST, fractional offsets and edge years are very helpful.

The new tests cover the behavior well. I left a few notes on merging some overlapping checks to keep the suite easier to maintain. None of them are blocking.

Comment thread tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php Outdated
Comment thread tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php Outdated
Comment thread tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php Outdated
…gistered.site` and `registered.gmt`.

Replaces the `registered_date` user field with a `registered` object holding the registration date in the site's timezone (`site`) and in GMT (`gmt`), like the `core/content-query` date fields. The `fields` input accepts `registered.site` and `registered.gmt` to select a single date, and rejects `registered_date`.

See #64657.
…ests.

Moves the `registered` output schema checks into the main schema test, checks the `fields` enum in output order there, and drops the tests and data provider rows that the other tests already cover.
@jorgefilipecosta
jorgefilipecosta force-pushed the update/users-query-registered-dates branch from 604d855 to f3158d3 Compare October 28, 2026 15:26
@jorgefilipecosta

Copy link
Copy Markdown
Member Author

Thank you for the review @gziolo, all the feedback was applied and I rebased the PR on trunk to pick up the entity actions test fix 😊

wporg-sync pushed a commit that referenced this pull request Oct 29, 2026
…gistered.site` and `registered.gmt`.

Replace the `registered_date` field with a `registered` object holding the registration date in the site's timezone (`site`) and in GMT (`gmt`), like the `core/content-query` date fields. The `fields` input accepts `registered.site` and `registered.gmt` to select a single date.

Developed in #15001.

Follow-up to [64346].

Props jorgefilipecosta, gziolo.
See #64657.

git-svn-id: https://develop.svn.wordpress.org/trunk@65002 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 29, 2026
…gistered.site` and `registered.gmt`.

Replace the `registered_date` field with a `registered` object holding the registration date in the site's timezone (`site`) and in GMT (`gmt`), like the `core/content-query` date fields. The `fields` input accepts `registered.site` and `registered.gmt` to select a single date.

Developed in WordPress/wordpress-develop#15001.

Follow-up to [64346].

Props jorgefilipecosta, gziolo.
See #64657.
Built from https://develop.svn.wordpress.org/trunk@65002


git-svn-id: http://core.svn.wordpress.org/trunk@64152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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