Skip to content

Improve network admin email change usability consistency. - #14247

Open
afercia wants to merge 1 commit into
WordPress:trunkfrom
afercia:network-admin-email-change
Open

afercia wants to merge 1 commit into
WordPress:trunkfrom
afercia:network-admin-email-change

Conversation

@afercia

@afercia afercia commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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

Use of AI Tools

NONE


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

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 afercia, johnjamesjacoby, realloc, therssoftware.

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

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.

@afercia
afercia requested review from JJJ and lloc October 13, 2026 15:05

@JJJ JJJ left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good consistency improvement. I found one remaining notice-state mismatch in the confirmation failure path that I think should be corrected before commit.

@@ -137,20 +143,51 @@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failed confirmation path above redirects with updated=false, but this condition checks only whether the argument is present. As a result, an invalid or expired confirmation link displays the success notice “Settings saved.” even though no setting changed. The analogous single-site flow also redirects with updated=false, but General Settings does not interpret its presence as success. Could this require the successful value before rendering the notice, or otherwise show an accurate failure notice? Since this PR is aligning notice behavior for this flow, I think it would be good to resolve the mismatch here.

delete_site_option( 'network_admin_hash' );
delete_site_option( 'new_admin_email' );
wp_redirect( network_admin_url( 'settings.php?updated=true' ) );
wp_redirect( network_admin_url( add_query_arg( array( 'updated' => 'true' ), 'settings.php' ) ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question

Does this mean that "Cancel request" redirects with updated=true, so it shows "Settings saved"?


if ( $pending_new_network_admin_email ) {
$message = sprintf(
/* translators: %s: New network admin email address. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Translator comment is indented one tab too little

$pending_network_admin_email_cancel_request_link = sprintf(
' <a href="%1$s">%2$s</a>',
esc_url( wp_nonce_url( network_admin_url( 'settings.php?dismiss=new_network_admin_email' ), 'dismiss_new_network_admin_email' ) ),
_x( 'Cancel request', 'network admin email change' )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question

New string context for "Cancel request" - can we reuse the existing 'admin email change'?

@robelsust

Copy link
Copy 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

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.

4 participants