Enhance super admin functions to accept network ID parameter and rela…#8921
Open
spenserhale wants to merge 1 commit intoWordPress:trunkfrom
Open
Enhance super admin functions to accept network ID parameter and rela…#8921spenserhale wants to merge 1 commit intoWordPress:trunkfrom
spenserhale wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Contributor
|
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 :) |
| } else { | ||
| return get_site_option( 'site_admins', array( 'admin' ) ); | ||
| } | ||
| return $super_admins ?? get_network_option($network_id ?? get_current_network_id(), 'site_admins', array('admin')); |
Member
There was a problem hiding this comment.
Better to check isset for $super_admins and return bail early.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.