Skip to content

Fix #23197: Conditionally define WP_INSTALLING in wp-activate.php so site plugins load on user-only activations#11499

Open
Vedanshmini26 wants to merge 1 commit intoWordPress:trunkfrom
Vedanshmini26:wp-activate-patch
Open

Fix #23197: Conditionally define WP_INSTALLING in wp-activate.php so site plugins load on user-only activations#11499
Vedanshmini26 wants to merge 1 commit intoWordPress:trunkfrom
Vedanshmini26:wp-activate-patch

Conversation

@Vedanshmini26
Copy link
Copy Markdown

Core Trac: https://core.trac.wordpress.org/ticket/23197

Problem
On a WordPress Multisite installation, visiting wp-activate.php does not load site-level plugins. This means plugins cannot hook into the activation process, making it impossible to run custom code on user or site activation. Only network-activated (must-use) plugins are available, which is an unreasonable workaround for plugin developers.

This also affects non-multisite installs where visiting wp-activate.php directly (e.g. via bots or exploits) causes PHP errors because the theme loads without plugins, breaking any theme code that depends on a plugin.

Root Cause
wp-activate.php unconditionally defines WP_INSTALLING = true before WordPress loads. This constant is checked inside wp_get_active_and_valid_plugins() in load.php, which returns an empty array when it is set — meaning site plugins are never loaded.

WP_INSTALLING exists in wp-activate.php for a valid reason: when a new blog is being activated on a subdomain that doesn't yet exist in wp_blogs, ms-settings.php uses it during bootstrap to load the main site's settings instead of the (non-existent) new site's settings — preventing a crash.

However, this is only necessary for new blog activations. User-only activations (no new blog/subdomain being created) have no such requirement, yet WP_INSTALLING is set for both cases unconditionally.

This creates a chicken-and-egg problem: WP_INSTALLING must be defined before WordPress loads, but you can only determine the activation type (new blog vs user-only) after WordPress loads by querying the signups table.

Notably, wp_get_active_and_valid_themes() already has a wp-activate.php exception that allows themes to load — but plugins have no equivalent exception, creating an inconsistency.

Solution
The activation type is encoded directly in the activation URL using a new_blog=1 query parameter, since the notification functions already know the activation type when generating the email.

src/wp-includes/ms-functions.php — wpmu_signup_blog_notification():
Appends &new_blog=1 to the activation URL in both URL construction paths (subdirectory and subdomain installs). wpmu_signup_user_notification() is intentionally left unchanged — user-only activation emails carry no new_blog parameter.

src/wp-activate.php:
Replaces the unconditional define( 'WP_INSTALLING', true ) with a conditional check:

if ( isset( $_GET['new_blog'] ) ) {
define( 'WP_INSTALLING', true );
}
This means:

New blog activations (?key=xxx&new_blog=1) → WP_INSTALLING is set → ms-settings.php bootstraps correctly for the new subdomain → consistent with previous behaviour
User-only activations (?key=xxx) → WP_INSTALLING is not set → site plugins load normally → bug fixed
Non-multisite visits → WP_INSTALLING is not set → plugins load, then immediate redirect → errors fixed

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 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 sheldorofazeroth.

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

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.

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.

1 participant