'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
-$wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer );
+$wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer );
$user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
// Execute confirmed email change. See send_confirmation_on_profile_email().
if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
- $new_email = get_option( $current_user->ID . '_new_email' );
- if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
+ $new_email = get_user_meta( $current_user->ID, '_new_email', true );
+ if ( $new_email && hash_equals( $new_email[ 'hash' ], $_GET[ 'newuseremail' ] ) ) {
$user = new stdClass;
$user->ID = $current_user->ID;
$user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
- if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
+ if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
+ }
wp_update_user( $user );
- delete_option( $current_user->ID . '_new_email' );
- wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
+ delete_user_meta( $current_user->ID, '_new_email' );
+ wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) );
die();
+ } else {
+ wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) );
}
-} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
- delete_option( $current_user->ID . '_new_email' );
+} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) {
+ check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' );
+ delete_user_meta( $current_user->ID, '_new_email' );
wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
die();
}
<?php else: ?>
<p><strong><?php _e('User updated.') ?></strong></p>
<?php endif; ?>
- <?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?>
+ <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
<p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('← Back to Users'); ?></a></p>
<?php endif; ?>
</div>
<?php endif; ?>
+<?php if ( isset( $_GET['error'] ) ) : ?>
+<div class="notice notice-error">
+ <?php if ( 'new-email' == $_GET['error'] ) : ?>
+ <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
+ <?php endif; ?>
+</div>
+<?php endif; ?>
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
<div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
<?php endif; ?>
<th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
<td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
<?php
- $new_email = get_option( $current_user->ID . '_new_email' );
+ $new_email = get_user_meta( $current_user->ID, '_new_email', true );
if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
<div class="updated inline">
<p><?php
printf(
- __( 'There is a pending change of your email to %1$s. <a href="%2$s">Cancel</a>' ),
- '<code>' . $new_email['newemail'] . '</code>',
- esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) )
- ); ?></p>
+ /* translators: %s: new email */
+ __( 'There is a pending change of your email to %s.' ),
+ '<code>' . esc_html( $new_email['newemail'] ) . '</code>'
+ );
+ printf(
+ ' <a href="%1$s">%2$s</a>',
+ esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
+ __( 'Cancel' )
+ );
+ ?></p>
</div>
<?php endif; ?>
</td>