Make WordPress Core

Opened 15 months ago

Last modified 6 months ago

#63536 accepted enhancement

Super Admin Functions Network ID Support

Reported by: spenserhale Owned by: johnjamesjacoby
Priority: normal Milestone: Future Release
Component: Networks and Sites Version:
Severity: normal Keywords: has-patch has-unit-tests needs-refresh
Cc: Focuses: multisite

Description

Multisite installs that host multiple networks currently treat all super-admin functions as being tied to the primary network. This limits enterprise-scale setups (e.g., SaaS platforms that shard customers into separate networks)

The patch introduces first-class, backward-compatible support for a $network_id argument in four super-admin helpers, allowing each network to maintain an independent site_admins list while preserving legacy behavior.

Scope of Code Changes
The four helpers—get_super_admins(), is_super_admin(), grant_super_admin(), and revoke_super_admin()—now accept an optional $network_id parameter.
They now call get_network_option() / update_network_option() when a network ID is supplied; otherwise they keep using the current network (maintaining old behaviour).
Early returns and the global $super_admins override are preserved exactly as before.

Design and Back-Compatibility
Calling without $network_id still works exactly as today.
Calling with a specific $network_id now targets that network’s site_admins row.
If $GLOBALSsuper_admins is defined, it still overrides everything and the new code short-circuits.
Plugin hooks (grant_super_admin, granted_super_admin, revoke_super_admin, revoked_super_admin) now receive $network_id as a second argument, but positional callbacks remain compatible.

All DocBlocks have been updated to describe the new parameter.
Hook signatures are extended but remain backward-compatible.
The change is fully transparent unless developers opt into the new argument.

Change History (5)

This ticket was mentioned in PR #8921 on WordPress/wordpress-develop by @spenserhale.


15 months ago
#1

  • Keywords has-patch has-unit-tests added

Trac ticket: https://core.trac.wordpress.org/ticket/63536#ticket

Multisite installs that host multiple networks currently treat all super-admin functions as being tied to the primary network. This limits enterprise-scale setups (e.g., SaaS platforms that shard customers into separate networks)

The patch introduces first-class, backward-compatible support for a $network_id argument in four super-admin helpers, allowing each network to maintain an independent site_admins list while preserving legacy behavior.

Scope of Code Changes
The four helpers—get_super_admins(), is_super_admin(), grant_super_admin(), and revoke_super_admin()—now accept an optional $network_id parameter.
They now call get_network_option() / update_network_option() when a network ID is supplied; otherwise they keep using the current network (maintaining old behaviour).
Early returns and the global $super_admins override are preserved exactly as before.

Design and Back-Compatibility
Calling without $network_id still works exactly as today.
Calling with a specific $network_id now targets that network’s site_admins row.
If $GLOBALSsuper_admins? is defined, it still overrides everything and the new code short-circuits.
Plugin hooks (grant_super_admin, granted_super_admin, revoke_super_admin, revoked_super_admin) now receive $network_id as a second argument, but positional callbacks remain compatible.

All DocBlocks have been updated to describe the new parameter.
Hook signatures are extended but remain backward-compatible.
The change is fully transparent unless developers opt into the new argument.
Created new tests to test functionality.

@audrasjb commented on PR #8921:


15 months ago
#2

Thanks for the PR! There are some coding standards issue to fix, see https://github.com/WordPress/wordpress-develop/pull/8921/files for the reported errors :)

#3 @johnjamesjacoby
9 months ago

  • Keywords needs-refresh added
  • Milestone Awaiting Review7.0
  • Owner set to johnjamesjacoby
  • Status newaccepted

#4 @immeet94
6 months ago

https://github.com/WordPress/wordpress-develop/pull/8921

I have tested this PR and can confirm that I did not encounter any errors or issues. The changes are working as expected and do not break existing functionality.

Thank you.

#5 @mukesh27
6 months ago

  • Milestone 7.0Future Release

Thanks @spenserhale for the ticket and PR!

As 7.0 Beta 1 is happening today and the PR 8921 didn't get initial code review from the owner and have some PHPCS issues at initial review, I’m moving this to Future Release to keep the milestone clean. That said, the door isn’t closed, if a stable patch can be prepared in the next few hours, feel free to move it back to the 7.0 milestone.

@johnjamesjacoby, would you be able to work on this and get it committed? If you’re unable to continue, please feel free to remove yourself as the owner so someone else can pick it up and move it forward.

Note: See TracTickets for help on using tickets.