Make WordPress Core

Ticket #23358: 23358.3.diff

File 23358.3.diff, 5.1 KB (added by MikeHansenMe, 7 years ago)

Refreshed

  • src/wp-admin/includes/ms.php

     
    315315        if ( $current_user->ID != $_POST['user_id'] )
    316316                return false;
    317317
     318        _user_new_email_compat( $current_user->ID );
     319
    318320        if ( $current_user->user_email != $_POST['email'] ) {
    319321                if ( !is_email( $_POST['email'] ) ) {
    320322                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address isn&#8217;t correct." ), array( 'form-field' => 'email' ) );
     
    323325
    324326                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
    325327                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
    326                         delete_option( $current_user->ID . '_new_email' );
     328                        delete_user_meta( $current_user->ID, '_new_email' );
    327329                        return;
    328330                }
    329331
     
    386388 * @since 3.0.0
    387389 */
    388390function new_user_email_admin_notice() {
    389         if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
    390                 echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
     391        if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) ) {
     392                _user_new_email_compat( get_current_user_id() );
     393                if ( $email = get_user_meta( get_current_user_id(), '_new_email', true ) )
     394                        echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
     395        }
    391396}
    392397add_action( 'admin_notices', 'new_user_email_admin_notice' );
    393398
  • src/wp-admin/includes/user.php

     
    440440        printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
    441441        echo '</p></div>';
    442442}
     443
     444/**
     445 * Pending e-mail changes used to be stored in options. This helps transition to user meta.
     446 *
     447 * @access private
     448 * @since 3.7.0
     449 */
     450function _user_new_email_compat( $user_id ) {
     451        if ( get_option( $user_id . '_new_email', false ) ) {
     452                update_user_meta( $user_id, '_new_email', get_option( $user_id . '_new_email' ) );
     453                delete_option( $user_id . '_new_email' );
     454        }
     455}
     456 No newline at end of file
  • src/wp-admin/user-edit.php

     
    9898
    9999// Execute confirmed email change. See send_confirmation_on_profile_email().
    100100if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
    101         $new_email = get_option( $current_user->ID . '_new_email' );
     101        _user_new_email_compat( $current_user->ID );
     102        $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    102103        if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
    103104                $user = new stdClass;
    104105                $user->ID = $current_user->ID;
     
    106107                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
    107108                        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
    108109                wp_update_user( $user );
    109                 delete_option( $current_user->ID . '_new_email' );
     110                delete_user_meta( $current_user->ID, '_new_email' );
    110111                wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    111112                die();
    112113        }
    113114} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
    114         delete_option( $current_user->ID . '_new_email' );
     115        _user_new_email_compat( $current_user->ID );
     116        delete_user_meta( $current_user->ID, '_new_email' );
    115117        wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    116118        die();
    117119}
     
    399401        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    400402        <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
    401403        <?php
    402         $new_email = get_option( $current_user->ID . '_new_email' );
     404        _user_new_email_compat( $current_user->ID );
     405        $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    403406        if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
    404407        <div class="updated inline">
    405408        <p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>