Groups: add site-provisioning admin tool, fix invisible settings modal, fix dbDelta schema bug - #1848
Merged
Merged
Conversation
Deputies previously had to hand-run wp_insert_site or wp site create to get a new site on the Groups network, since no creation flow existed. Adds a Network Admin > Sites > Add Group Site screen that creates the site, switches it to the groups-site theme, strips the default WP boilerplate content, and seeds the Members page the theme's template needs, all gated behind manage_sites. See #1782. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…role current_user_can_manage_events() checked the user's role array directly instead of calling current_user_can(), so it didn't pick up core's super-admin capability elevation the way current_user_can_manage_group_settings() does. A super admin whose nominal role on a given group is subscriber (e.g. a deputy checking in on a group they don't personally organise) would see the "Set up your group" button, but Modal::enqueue_supplementary_assets() -- gated on current_user_can_manage_events() -- never enqueued the wp-components/wp-block-editor styles the modal needs, so it rendered with no CSS and was effectively invisible. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The sponsor-invoice-index table schema was missing a comma between two KEY definitions, which corrupted dbDelta's index diffing and made it emit a malformed ALTER TABLE ... ADD `` (``) query. Since upgrade_database() runs on every network-admin page load until the version bump succeeds, this fataled every Network Admin screen on every network on any install still missing the last_modified index. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Add missing docblock on Test_Group_Site_Provisioning::wpSetUpBeforeClass(). - Replace the direct $GLOBALS['super_admins'] override (prohibited by WordPress.WP.GlobalVariablesOverride) with grant_super_admin()/ revoke_super_admin(), resetting the site_admins site option to a clean array first since other tests in the suite can leave it in a shape grant_super_admin() doesn't expect. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Groups-network provisioning tool and related regressions/tests, while also addressing two production-impacting issues: super-admin capability detection in the Groups frontend and a dbDelta() schema bug in wordcamp-payments-network.
Changes:
- Add a Network Admin → Sites → “Add Group Site” screen plus
create_group_site()helper to provision preconfigured group sites. - Fix “invisible settings modal” root cause by treating super admins as event managers in
current_user_can_manage_events(), and add a regression test. - Fix malformed
dbDelta()schema (missing comma betweenKEYdefinitions) that could generate invalidALTER TABLESQL.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| public_html/wp-content/plugins/wordcamp-payments-network/includes/sponsor-invoices-dashboard.php | Fixes SQL schema formatting so dbDelta() index diffs don’t generate malformed ALTERs. |
| public_html/wp-content/mu-plugins/wporg-groups-frontend/inc/capabilities.php | Updates event-management permission helper to explicitly recognize super admins. |
| public_html/wp-content/mu-plugins/wporg-groups-frontend/tests/test-capabilities.php | Adds regression coverage for super-admin-with-subscriber-role behavior (needs cleanup hardening). |
| public_html/wp-content/mu-plugins/groups/tests/test-group-site-provisioning.php | Adds PHPUnit coverage for group-site provisioning flows (one assertion needs strengthening). |
| public_html/wp-content/mu-plugins/groups/tests/bootstrap.php | Ensures required MU-plugin files (logger + provisioning code) are loaded in the suite. |
| public_html/wp-content/mu-plugins/groups/group-site-provisioning.php | Implements the admin UI + provisioning logic (needs timezone validation + Members page error handling). |
- Validate `timezone_string` against `timezone_identifiers_list()` in `create_group_site()` and fail early with `invalid_timezone` -- previously an invalid identifier would be persisted unvalidated and could later throw when WordPress calls `wp_timezone()`. - Check the Members page `wp_insert_post()` result and log `members_page_failed` if it errors, instead of silently ignoring it. - Strengthen `test_rejects_unknown_organizer()` to assert no new site was created (matching the duplicate-slug test), rather than checking for a page slug the success path would never create anyway. - Guarantee `revoke_super_admin()` runs in the super-admin regression test even if the assertion fails, so the test user's super-admin status can't leak into later tests in the suite. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
bor0
commented
Aug 6, 2026
bor0
commented
Aug 6, 2026
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.

Fixes #1782
Summary
wp_insert_site()/wp site createon the sandbox.current_user_can_manage_events()used a role-array check that didn't recognize super-admin capability elevation the waycurrent_user_can_manage_group_settings()does, so a super admin without an explicit editor/admin role on a given group saw the settings button but the modal rendered with no CSS (mounted in the DOM, but invisible —position: static, transparent background).wordcamp-payments-network: a missing comma between twoKEYdefinitions corrupteddbDelta()'s index diffing, generating a malformedALTER TABLE ... ADD `` (``)query that fataled every Network Admin page load on any install still missing thelast_modifiedindex. Found while verifying the above through the actual browser UI.Test plan
Automated
Test_Group_Site_Provisioning(happy path, duplicate slug, unknown organizer, invalid slug) — new, passing.Test_Groups_Capabilities::test_super_admin_can_manage_events_despite_subscriber_role— new regression test, passing.BASE_REF=production php .github/bin/phpcs-branch.php— clean.Manual (local dev —
events.wordpress.test)Steps below use the local Docker dev domain (
events.wordpress.test); on a real deploy substituteevents.wordpress.org.Group site provisioning
events.wordpress.test/group/wp-admin/network/sites.php?page=add-group-site).events.wordpress.test/group/{slug}/.groups-sitetheme is active,/members/resolves (not a 404) and lists the organiser, and there's no leftover "Hello world!"/"Sample Page" boilerplate.blogdescriptionwas left blank on purpose).Settings modal visibility
dbDelta fix
This only manifests on an install whose
{prefix}wcbd_sponsor_invoice_indextable already exists but predates thelast_modifiedindex (i.e.wcbdsi_database_versionsite option < 4 on a given network). On such an install, before this fix, any Network Admin page load fatals withWordPress database error: ... ALTER TABLE ... ADD `` (``); after this fix,dbDelta()correctly generatesALTER TABLE ... ADD KEY last_modified (last_modified)and Network Admin loads normally on every network.Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com