Skip to content

Users: Add id="user-{ID}" to rows on WP_MS_Users_List_Table#11600

Open
dd32 wants to merge 1 commit intoWordPress:trunkfrom
dd32:fix/65102-ms-users-list-row-id
Open

Users: Add id="user-{ID}" to rows on WP_MS_Users_List_Table#11600
dd32 wants to merge 1 commit intoWordPress:trunkfrom
dd32:fix/65102-ms-users-list-row-id

Conversation

@dd32
Copy link
Copy Markdown
Member

@dd32 dd32 commented Apr 20, 2026

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

Summary

WP_Users_List_Table::single_row() (per-site wp-admin/users.php) renders each user row with id="user-{ID}". WP_MS_Users_List_Table::display_rows() (network wp-admin/network/users.php) does not — it emits <tr class="…"> with no row id at all.

This one-line change brings the network list in line with the per-site list.

Why

Without a row id, plugin and assistive-tech code that decorates / anchors / focuses specific user rows on the network screen has to fall back to finding the bulk-action checkbox (#blog_{ID}) and walking .closest('tr') — brittle if the checkbox column is ever moved or renamed.

Change

-            <tr class="<?php echo trim( $class ); ?>">
+            <tr id="user-<?php echo (int) $user->ID; ?>" class="<?php echo trim( $class ); ?>">

Additive — existing consumers of the class attribute are unaffected; new consumers gain the same stable hook the per-site list already exposes.

Test plan

  • Load wp-admin/network/users.php on a multisite install and confirm each <tr> carries id="user-{ID}" matching the user's ID.
  • Confirm the per-site wp-admin/users.php is unchanged.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 20, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props dd32.

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

Brings the network Users list in line with `WP_Users_List_Table::single_row()`,
which has always emitted `<tr id="user-{ID}">`. Without a row id, plugin and
assistive-tech code that targets specific rows has to fall back to walking
from the bulk-action checkbox (`#blog_{ID}`) up via `.closest('tr')`.

Additive: existing consumers of the `class` attribute are unaffected.

See https://core.trac.wordpress.org/ticket/65102.
@dd32 dd32 force-pushed the fix/65102-ms-users-list-row-id branch from fbff6cc to 270f96f Compare April 20, 2026 03:14
@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.


?>
<tr class="<?php echo trim( $class ); ?>">
<tr id="user-<?php echo (int) $user->ID; ?>" class="<?php echo trim( $class ); ?>">
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.

Casting here not necessary here

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.

It doesn't hurt though. Since WP_User::$ID doesn't have a PHP property type specified, technically someone could populate a $user->ID = '" onclick="alert(1)'.

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.

3 participants