Make WordPress Core

Ticket #23358: 23358.4.diff

File 23358.4.diff, 4.8 KB (added by MikeHansenMe, 8 years ago)
  • src/wp-admin/includes/ms.php

     
    329329        if ( $current_user->ID != $_POST['user_id'] )
    330330                return false;
    331331
     332        _user_new_email_compat( $current_user->ID );
     333
    332334        if ( $current_user->user_email != $_POST['email'] ) {
    333335                if ( !is_email( $_POST['email'] ) ) {
    334336                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address isn&#8217;t correct." ), array( 'form-field' => 'email' ) );
     
    337339
    338340                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
    339341                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
    340                         delete_option( $current_user->ID . '_new_email' );
     342                        delete_user_meta( $current_user->ID, '_new_email' );
    341343                        return;
    342344                }
    343345
     
    400402 * @since 3.0.0
    401403 */
    402404function new_user_email_admin_notice() {
    403         if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
    404                 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>";
     405        if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) ) {
     406                _user_new_email_compat( get_current_user_id() );
     407                if ( $email = get_user_meta( get_current_user_id(), '_new_email', true ) )
     408                        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>";
     409        }
    405410}
    406411
    407412/**
  • src/wp-admin/includes/user.php

     
    516516Please click the following link to activate your user account:
    517517%%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) );
    518518}
     519
     520/**
     521 * Pending e-mail changes used to be stored in options. This helps transition to user meta.
     522 *
     523 * @access private
     524 * @since 3.7.0
     525 */
     526function _user_new_email_compat( $user_id ) {
     527        if ( get_option( $user_id . '_new_email', false ) ) {
     528                update_user_meta( $user_id, '_new_email', get_option( $user_id . '_new_email' ) );
     529                delete_option( $user_id . '_new_email' );
     530        }
     531}
     532 No newline at end of file
  • src/wp-admin/user-edit.php

     
    8282
    8383// Execute confirmed email change. See send_confirmation_on_profile_email().
    8484if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
    85         $new_email = get_option( $current_user->ID . '_new_email' );
     85        _user_new_email_compat( $current_user->ID );
     86        $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    8687        if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
    8788                $user = new stdClass;
    8889                $user->ID = $current_user->ID;
     
    9091                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
    9192                        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
    9293                wp_update_user( $user );
    93                 delete_option( $current_user->ID . '_new_email' );
     94                delete_user_meta( $current_user->ID, '_new_email' );
    9495                wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    9596                die();
    9697        }
    9798} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
    98         delete_option( $current_user->ID . '_new_email' );
     99        _user_new_email_compat( $current_user->ID );
     100        delete_user_meta( $current_user->ID, '_new_email' );
    99101        wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    100102        die();
    101103}
     
    383385        <th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    384386        <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
    385387        <?php
    386         $new_email = get_option( $current_user->ID . '_new_email' );
     388        _user_new_email_compat( $current_user->ID );
     389        $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    387390        if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
    388391        <div class="updated inline">
    389392        <p><?php