Make WordPress Core

Opened 6 weeks ago

Last modified 6 weeks ago

#66193 new defect (bug)

wpmu_activate_signup() reports a password that was never set when the user already exists

Reported by: abhishekfdd Owned by:
Priority: normal Milestone: Awaiting Review
Component: Login and Registration Version: 3.0
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

In wpmu_activate_signup(), $password is generated before the username_exists() check. If the user already exists and the signup includes a site, that password is never applied to the account, but it is still:

  • passed to the wpmu_activate_blog action,
  • emailed by wpmu_welcome_notification() through the default Password: PASSWORD template,
  • displayed on wp-activate.php.

[49078] documented $password as "User password, or "N/A" if the user account is not new" for wpmu_welcome_notification(), and wp-admin/network/site-new.php already passes 'N/A', but wpmu_activate_signup() never does.

Steps to reproduce

  1. On a multisite with site registration enabled, create a site signup for a new user via wp-signup.php.
  2. Make the first activation fail during site creation, for example by adding an error on wp_validate_site_data. The user is created, the site is not.
  3. Visit the activation link again.

Expected: the page and welcome email do not show a password, since none was generated for the account.
Actual: the site is created, and the page and welcome email show a new password that does not work. The password set on the first attempt was never shown to anyone, so the user can only get in via password reset.

Reachability

Not reachable through wp-signup.php validation alone, since wpmu_validate_user_signup() rejects existing usernames. It is reachable when site creation fails partway and the link is retried, with concurrent activations of the same key, and when plugins call wpmu_signup_blog() for existing users.

Proposed fix

Generate the password only when the user is created in wpmu_activate_signup(), otherwise use 'N/A', matching the docblock and site-new.php. Patch and unit tests to follow.

Related: #38474 (PR 8710 also modifies wpmu_activate_signup() and adds a test class named Tests_Multisite_wpmuActivateSignup), #33209, #31127.

Attachments (1)

66193.diff​ (5.4 KB ) - added by abhishekfdd 6 weeks ago.

Download all attachments as: .zip

Change History (2)

This ticket was mentioned in ​PR #13778 on ​WordPress/wordpress-develop by ​@abhishekfdd.


6 weeks ago
#1

  • Keywords has-patch has-unit-tests added

Generates the activation password in wpmu_activate_signup() only when the user is actually created. When the user already exists, 'N/A' is passed to wpmu_activate_blog, the welcome email and wp-activate.php, matching the documented behavior from [49078] and what network/site-new.php already does.

Adds tests for:

  • new user with site: returned password works (regression guard),
  • existing user: 'N/A' returned, existing password unchanged,
  • retry after a failed site creation: 'N/A' returned and in the welcome email.

See #66193.

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

Use of AI Tools

AI assistance: Yes
Tool: Claudecode
Model(s): Opus 5.5
Used for: Initial code skeleton and test suggestions; final implementation and tests were reviewed and edited by me.

Note: See TracTickets for help on using tickets.