From 2c0c94d06dc96ba7e03fba240951893b3480f8ae Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 2 Oct 2026 12:44:38 +0200 Subject: [PATCH 1/3] Make change emails admin notices more consistent. --- src/wp-admin/includes/admin-filters.php | 1 - src/wp-admin/options-general.php | 22 ++++++++++++++++++---- src/wp-admin/user-edit.php | 11 +++++++++-- src/wp-includes/user.php | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/includes/admin-filters.php b/src/wp-admin/includes/admin-filters.php index 5337cc02c88c9..8f77f605fac93 100644 --- a/src/wp-admin/includes/admin-filters.php +++ b/src/wp-admin/includes/admin-filters.php @@ -120,7 +120,6 @@ add_action( 'admin_init', 'default_password_nag_handler' ); add_action( 'admin_notices', 'default_password_nag' ); -add_action( 'admin_notices', 'new_user_email_admin_notice' ); add_action( 'profile_update', 'default_password_nag_edit_user', 10, 2 ); diff --git a/src/wp-admin/options-general.php b/src/wp-admin/options-general.php index c1efa0c063c58..9b43180b53085 100644 --- a/src/wp-admin/options-general.php +++ b/src/wp-admin/options-general.php @@ -22,6 +22,9 @@ /* translators: Date and time format for exact current time, mainly about timezones, see https://www.php.net/manual/datetime.format.php */ $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' ); +$new_admin_email = get_option( 'new_admin_email' ); +$pending_new_admin_email = $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email; + add_action( 'admin_head', 'options_general_add_js' ); $options_help = '

' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '

' . @@ -67,6 +70,17 @@

+' . esc_html( $new_admin_email ) . '' + ); + wp_admin_notice( $message, array( 'type' => 'info' ) ); +} +?> +
@@ -266,11 +280,10 @@ class=""

The new address will not become active until confirmed.' ); ?>

' . esc_html( $new_admin_email ) . '' ); $pending_admin_email_message .= sprintf( @@ -281,7 +294,8 @@ class="" wp_admin_notice( $pending_admin_email_message, array( - 'additional_classes' => array( 'updated', 'inline' ), + 'type' => 'info', + 'additional_classes' => array( 'inline' ), ) ); } diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 9a31f13e58d29..ba95c97cf5317 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -266,9 +266,15 @@

- +

+ + @@ -601,7 +607,8 @@ wp_admin_notice( $pending_change_message, array( - 'additional_classes' => array( 'updated', 'inline' ), + 'type' => 'info', + 'additional_classes' => array( 'inline' ), ) ); endif; diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 92d091165525b..6436bdd4a0f24 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -4015,7 +4015,7 @@ function send_confirmation_on_profile_email( $user_id = 0 ) { function new_user_email_admin_notice() { global $pagenow; - if ( 'profile.php' === $pagenow && isset( $_GET['updated'] ) ) { + if ( 'profile.php' === $pagenow ) { $email = get_user_meta( get_current_user_id(), '_new_email', true ); if ( $email ) { $message = sprintf( From fc8fcd9cec03fc7370399241fce5d6b04f22f210 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 2 Oct 2026 13:31:03 +0200 Subject: [PATCH 2/3] Add admin email change success notice. --- src/wp-admin/options-general.php | 12 ++++++++++++ src/wp-admin/options.php | 10 ++++++++-- src/wp-includes/functions.php | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/options-general.php b/src/wp-admin/options-general.php index 9b43180b53085..33ec0a8041816 100644 --- a/src/wp-admin/options-general.php +++ b/src/wp-admin/options-general.php @@ -71,6 +71,18 @@

' . __( 'Administration email updated.' ) . ''; + wp_admin_notice( + $message, + array( + 'id' => 'message', + 'dismissible' => true, + 'type' => 'success', + ) + ); +} + if ( $pending_new_admin_email ) { $message = sprintf( /* translators: %s: New administration email address. */ diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php index 9413eb3b1a93b..8f065f64473e6 100644 --- a/src/wp-admin/options.php +++ b/src/wp-admin/options.php @@ -57,7 +57,7 @@ // Handle admin email change requests. if ( ! empty( $_GET['adminhash'] ) ) { $new_admin_details = get_option( 'adminhash' ); - $redirect = 'options-general.php?updated=false'; + $redirect = add_query_arg( array( 'updated' => 'false' ), 'options-general.php' ); if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['adminhash'] ) @@ -66,7 +66,13 @@ update_option( 'admin_email', $new_admin_details['newemail'] ); delete_option( 'adminhash' ); delete_option( 'new_admin_email' ); - $redirect = 'options-general.php?updated=true'; + $redirect = add_query_arg( + array( + 'updated' => 'true', + 'admin_email_updated' => 'true', + ), + 'options-general.php', + ); } wp_redirect( admin_url( $redirect ) ); diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 393f50a3aad58..2227da2458708 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1264,6 +1264,7 @@ function wp_removable_query_args() { 'activate', 'activated', 'admin_email_remind_later', + 'admin_email_updated', 'approved', 'core-major-auto-updates-saved', 'deactivate', From 7d8fd38a5da717c9924a6166d2d6d1aa787b08d3 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 2 Oct 2026 15:02:55 +0200 Subject: [PATCH 3/3] Add cancel request link to all the related admin notices. --- src/wp-admin/options-general.php | 15 +++++++++------ src/wp-admin/user-edit.php | 2 +- src/wp-includes/user.php | 8 +++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/options-general.php b/src/wp-admin/options-general.php index 33ec0a8041816..1e6e00ea703d8 100644 --- a/src/wp-admin/options-general.php +++ b/src/wp-admin/options-general.php @@ -83,12 +83,19 @@ ); } +$pending_admin_email_cancel_request_link = sprintf( + ' %2$s', + esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ), + _x( 'Cancel request', 'admin email change' ) +); + if ( $pending_new_admin_email ) { $message = sprintf( /* translators: %s: New administration email address. */ __( 'The administration email address has not been updated yet. Please check the inbox at %s for a confirmation email.' ), '' . esc_html( $new_admin_email ) . '' ); + $message .= $pending_admin_email_cancel_request_link; wp_admin_notice( $message, array( 'type' => 'info' ) ); } ?> @@ -294,15 +301,11 @@ class="" ' . esc_html( $new_admin_email ) . '' ); - $pending_admin_email_message .= sprintf( - ' %2$s', - esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ), - __( 'Cancel' ) - ); + $pending_admin_email_message .= $pending_admin_email_cancel_request_link; wp_admin_notice( $pending_admin_email_message, array( diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index ba95c97cf5317..b27dcac8eec90 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -602,7 +602,7 @@ $pending_change_message .= sprintf( ' %2$s', esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ), - __( 'Cancel' ) + _x( 'Cancel request', 'user email change' ) ); wp_admin_notice( $pending_change_message, diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 6436bdd4a0f24..f466de798c3d6 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -4016,13 +4016,19 @@ function new_user_email_admin_notice() { global $pagenow; if ( 'profile.php' === $pagenow ) { - $email = get_user_meta( get_current_user_id(), '_new_email', true ); + $current_user_id = get_current_user_id(); + $email = get_user_meta( $current_user_id, '_new_email', true ); if ( $email ) { $message = sprintf( /* translators: %s: New email address. */ __( 'Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.' ), '' . esc_html( $email['newemail'] ) . '' ); + $message .= sprintf( + ' %2$s', + esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user_id . '_new_email' ), 'dismiss-' . $current_user_id . '_new_email' ) ), + _x( 'Cancel request', 'user email change' ), + ); wp_admin_notice( $message, array( 'type' => 'info' ) ); } }