Make WordPress Core

Opened 4 weeks ago

Closed 9 days ago

#66300 closed defect (bug) (fixed)

Improve usability and consistency of the network admin email change notices.

Reported by: afercia Owned by: lancewillett
Priority: normal Milestone: 7.2
Component: Networks and Sites Version:
Severity: normal Keywords: has-patch has-screenshots has-unit-tests
Cc: Focuses:

Description

Follow up to #66173.

For consistency with the changes in #66173 for the single site user and administration notices, also the network admin change notices should be improved in terms of clarity of the admin notices and usability.

Basically:

  • Add an info notice at the top.
  • Change the type of the notice in the middle of the page to 'info'.
  • Change the cancel link text to 'Cancel request'.
  • Provide the link in both notices.
  • After clicking the activation link in the confirmation email, add a success notice Network admin email updated..
  • Settings saved. should be bold, for consistency with single site settings.

Attachments (2)

01 network admin email.png​ (209.5 KB ) - added by afercia 4 weeks ago.
02 network admin email.png​ (140.4 KB ) - added by afercia 4 weeks ago.

Download all attachments as: .zip

Change History (14)

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


4 weeks ago
#1

  • Keywords has-patch added

Use of AI Tools

NONE

#2 @afercia
4 weeks ago

In ​PR 14247:

  • Adds an 'info' admin notice in the Network Settings page when changing the network admin email.
  • The notice is similar to the one already rendered on single site.
  • The notice at the top is rendered after the 'Settings saved.' one.
  • The notice in the middle of the page is now of type 'info'.
  • The 'Cancel' link text is now a more meaningful 'Cancel request'.
  • The 'Cancel request' link is now rendered in both the admin notices.
  • After clicking the activation link in the confirmation email, a success notice Network admin email updated. is rendered at the top of the page.
  • Improves the redirect links by using add_query_arg().
  • The standard Settings saved. notice text is now bold, for consistency with the single site settings.

#3 @afercia
4 weeks ago

  • Keywords has-screenshots added

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


4 weeks ago
#4

  • Keywords has-unit-tests added

Follow-up to: ​https://github.com/WordPress/wordpress-develop/pull/14247

Description

This PR addresses review feedback from @JJJ and @lloc on #14247 and introduces a dedicated unit test suite:

  1. Fix false-positive "Settings saved." notice on failed confirmation: When an invalid or expired confirmation link is clicked, the flow redirects to settings.php?updated=false. Because the check previously evaluated isset( $_GET['updated'] ), WordPress falsely rendered the green "Settings saved." notice even though no setting was changed. The check now requires isset( $_GET['updated'] ) && 'true' === $_GET['updated'].
  2. Fix "Cancel request" notice behavior: Clicking "Cancel request" no longer redirects with ?updated=true. It redirects cleanly to settings.php without triggering the "Settings saved." notice.
  3. Reuse existing translation context: Reused _x( 'Cancel request', 'admin email change' ) to align with wp-admin/options-general.php and avoid adding a duplicate translatable string for polyglots.
  4. Translator comment formatting: Fixed the translator comment indentation to match the sprintf() parameter indent level.
  5. Add dedicated PHPUnit tests: Created tests/phpunit/tests/multisite/networkAdminEmailChange.php covering email change initiation, valid/invalid hash confirmation, option cleanup, notice display conditions, and removable query args.

Testing Instructions

  1. In a Multisite install, go to Network Admin -> Settings -> Network Settings (/wp-admin/network/settings.php).
  2. Change the Network Admin Email to a new address and save settings.
  3. Verify the pending info notice appears with the new email and a "Cancel request" link.
  4. Visit /wp-admin/network/settings.php?network_admin_hash=invalidhash:
    • Verify it redirects to settings.php?updated=false.
    • Verify "Settings saved." is NOT displayed.
  5. Click "Cancel request":
    • Verify the pending notice is dismissed and "Settings saved." is NOT displayed.
  6. Run PHPUnit and PHPCS:
    vendor/bin/phpunit -c tests/phpunit/multisite.xml tests/phpunit/tests/multisite/networkAdminEmailChange.php
       vendor/bin/phpcs src/wp-admin/network/settings.php tests/phpunit/tests/multisite/networkAdminEmailChange.php
    
---

== 2. GitHub PR #14247 Comment (Review Response) ==

}}}markdown
I have investigated the review feedback from @JJJ and @lloc and prepared the fixes and dedicated unit tests:

1. **Failed confirmation notice mismatch:**
   Changed `isset( $_GET['updated'] )` to `isset( $_GET['updated'] ) && 'true' === $_GET['updated'] && ! isset( $_GET['network_admin_email_updated'] )` in `wp-admin/network/settings.php`. When an invalid or expired hash redirects with `updated=false`, the "Settings saved." notice is no longer rendered, matching single-site behavior.
2. **Cancel request redirect:**
   Changed the dismiss action to redirect to `network_admin_url( 'settings.php' )` without `updated=true` so that cancelling a pending request does not display "Settings saved.".
3. **Reused context:**
   Updated `_x( 'Cancel request', 'network admin email change' )` to reuse `_x( 'Cancel request', 'admin email change' )` from `options-general.php`.
4. **Indentation:**
   Fixed the translator comment indentation in `wp-admin/network/settings.php`.
5. **Unit tests:**
   Added `tests/phpunit/tests/multisite/networkAdminEmailChange.php` with 10 test cases (27 assertions) covering email change initiation, confirmation hash validation, cancellation cleanup, notice display logic, and removable query args.

Branch with the patch: `robelsust:fix/66300-network-admin-email-usability`

​@therssoftware commented on ​PR #14247:


4 weeks ago
#5

I have investigated the review feedback from @JJJ and @lloc and prepared the fixes and dedicated unit tests:

  1. Failed confirmation notice mismatch: Changed isset( $_GET['updated'] ) to isset( $_GET['updated'] ) && 'true' === $_GET['updated'] && ! isset( $_GET['network_admin_email_updated'] ) in wp-admin/network/settings.php. When an invalid or expired hash redirects with updated=false, the "Settings saved." notice is no longer rendered, matching single-site behavior.
  2. Cancel request redirect: Changed the dismiss action to redirect to network_admin_url( 'settings.php' ) without updated=true so that cancelling a pending request does not display "Settings saved.".
  3. Reused context: Updated _x( 'Cancel request', 'network admin email change' ) to reuse _x( 'Cancel request', 'admin email change' ) from options-general.php.
  4. Indentation: Fixed the translator comment indentation in wp-admin/network/settings.php.
  5. Unit tests: Added tests/phpunit/tests/multisite/networkAdminEmailChange.php with 10 test cases (27 assertions) covering email change initiation, confirmation hash validation, cancellation cleanup, notice display logic, and removable query args.

Branch with the patch: robelsust:fix/66300-network-admin-email-usability

#6 @therssoftware
4 weeks ago

Follow-up to the review on PR 14247:

  • Fixed the updated=false false-positive success notice when an invalid or expired confirmation link is accessed. wp-admin/network/settings.php now requires isset( $_GET['updated'] ) && 'true' === $_GET['updated'] before rendering the "Settings saved." notice.
  • Updated the dismiss/cancel request redirect to point to settings.php without updated=true, preventing the false "Settings saved." notice upon cancelling.
  • Reused the existing 'admin email change' gettext context for "Cancel request" to maintain consistency with single-site (options-general.php) and avoid adding duplicate strings for polyglots.
  • Fixed the translator comment indentation in settings.php.
  • Added dedicated unit tests in tests/phpunit/tests/multisite/networkAdminEmailChange.php (10 tests, 27 assertions, all passing).

​@therssoftware commented on ​PR #14466:


11 days ago
#7

Thank you for the review ​@lancewillett

I have updated the branch with the following changes:

Removed the confirmation, cancellation, and notice predicate tests from networkAdminEmailChange.php that duplicated settings.php logic rather than exercising production code directly.
Retained the 3 email-initiation tests covering update_network_option_new_admin_email() with mock_sent mailer inspection and resets in set_up() and tear_down().
Added dedicated #66300 test coverage for network_admin_email_updated in tests/phpunit/tests/functions/wpRemovableQueryArgs.php.
Cleaned up redundant DB option deletes in tear_down() to rely on test runner transaction management.

​@lancewillett commented on ​PR #14466:


11 days ago
#8

@JJJ, could you take a fresh look at the network-admin notice behavior here, following your review of #14247? The revised patch removes the copied-handler tests and addresses the misleading success-notice paths, but it still changes production confirmation, cancellation, and pending-email notices.

I'm holding this for that review and browser validation of those flows. The remaining PHPUnit tests cover email initiation; they do not establish that the rendered notices are correct. Please also trim the PR description's coverage claims to match the tests now present.

<sub>AI review · <code>gpt-6</code></sub>

​@therssoftware commented on ​PR #14466:


10 days ago
#9

Thanks @lancewillett and @Copilot.

I have updated the PR description to trim the PHPUnit test coverage claims to match the tests present in tests/phpunit/tests/multisite/networkAdminEmailChange.php.

The automated PHPUnit suite specifically covers the programmatic core functions:

  • Network admin email change initiation via update_network_option_new_admin_email() (handling identical emails, invalid formats, hash generation, and email dispatch).
  • Removable query args via wp_removable_query_args().

The UI-level confirmation (?network_admin_hash=...), cancellation link (?dismiss=new_network_admin_email), and notice rendering in wp-admin/network/settings.php are legacy procedural screen flows that redirect/exit, which are verified through the manual browser testing steps detailed above.

​@lancewillett commented on ​PR #14466:


10 days ago
#10

Browser verification passed on e843250bbc85ab3f8e6a58cd6c14cfe6c1fa3a69 in an isolated PHP 8.3 multisite install: both pending notices and cancellation links, invalid/stale confirmations, successful email confirmation, and an ordinary settings save behaved as expected. Confirmation emails were captured locally.

This checks the current patch, not a before/after comparison. The requested independent review remains pending before landing.

<sub>AI review · <code>gpt-6</code></sub>

​@therssoftware commented on ​PR #14466:


9 days ago
#11

Hi @JJJ,

Good catch! I've removed the duplicate assertion from networkAdminEmailChange.php so the dedicated test in wpRemovableQueryArgs.php covers network_admin_email_updated exclusively. All tests and PHPCS checks pass cleanly.

Thank you so much for the thorough review and testing!

#12 @lancewillett
9 days ago

  • Owner set to lancewillett
  • Resolution → fixed
  • Status new → closed

In 65240:

Networks and Sites: Clarify the network admin email change notices.

Bring the network admin email change flow in line with the single site notices. Show a pending change as an info notice at the top of Network Settings and next to the email field, both with a "Cancel request" link. After the confirmation link is followed, show "Network admin email updated." instead of "Settings saved."

Show "Settings saved." only when updated=true, and in bold, so a failed confirmation or a canceled request no longer reports a save. Add network_admin_email_updated to wp_removable_query_args().

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/14247, ​https://github.com/WordPress/wordpress-develop/pull/14466

Props therssoftware, afercia, johnjamesjacoby, realloc.
Fixes #66300.

Note: See TracTickets for help on using tickets.