WordPress.org

Make WordPress Core

Ticket #23358: 23358.diff

File 23358.diff, 5.4 KB (added by kovshenin, 8 years ago)
  • src/wp-admin/user-edit.php

     
    8080
    8181// Execute confirmed email change. See send_confirmation_on_profile_email().
    8282if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
    83         $new_email = get_option( $current_user->ID . '_new_email' );
     83        _user_new_email_compat( $current_user->ID );
     84        $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    8485        if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
    8586                $user = new stdClass;
    8687                $user->ID = $current_user->ID;
     
    8889                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
    8990                        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
    9091                wp_update_user( $user );
    91                 delete_option( $current_user->ID . '_new_email' );
     92                delete_user_meta( $current_user->ID, '_new_email' );
    9293                wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    9394                die();
    9495        }
    9596} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
    96         delete_option( $current_user->ID . '_new_email' );
     97        _user_new_email_compat( $current_user->ID );
     98        delete_user_meta( $current_user->ID, '_new_email' );
    9799        wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    98100        die();
    99101}
     
    335337        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    336338        <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" />
    337339        <?php
    338         $new_email = get_option( $current_user->ID . '_new_email' );
     340        _user_new_email_compat( $current_user->ID );
     341        $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    339342        if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
    340343        <div class="updated inline">
    341344        <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>
  • src/wp-admin/includes/ms.php

     
    225225        if ( $current_user->ID != $_POST['user_id'] )
    226226                return false;
    227227
     228        _user_new_email_compat( $current_user->ID );
     229
    228230        if ( $current_user->user_email != $_POST['email'] ) {
    229231                if ( !is_email( $_POST['email'] ) ) {
    230232                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address isn&#8217;t correct." ), array( 'form-field' => 'email' ) );
     
    233235
    234236                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
    235237                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
    236                         delete_option( $current_user->ID . '_new_email' );
     238                        delete_user_meta( $current_user->ID, '_new_email' );
    237239                        return;
    238240                }
    239241
     
    242244                                'hash' => $hash,
    243245                                'newemail' => $_POST['email']
    244246                                );
    245                 update_option( $current_user->ID . '_new_email', $new_user_email );
     247                update_user_meta( $current_user->ID, '_new_email', $new_user_email );
    246248
    247249                $content = apply_filters( 'new_user_email_content', __( "Dear user,
    248250
     
    271273add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
    272274
    273275function new_user_email_admin_notice() {
    274         if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
    275                 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>";
     276        if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) ) {
     277                _user_new_email_compat( get_current_user_id() );
     278                if ( $email = get_user_meta( get_current_user_id(), '_new_email', true ) )
     279                        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>";
     280        }
    276281}
    277282add_action( 'admin_notices', 'new_user_email_admin_notice' );
    278283
  • src/wp-admin/includes/user.php

     
    371371        printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
    372372        echo '</p></div>';
    373373}
     374
     375/**
     376 * Pending e-mail changes used to be stored in options. This helps transition to user meta.
     377 *
     378 * @access private
     379 * @since 3.7.0
     380 */
     381function _user_new_email_compat( $user_id ) {
     382        if ( get_option( $user_id . '_new_email', false ) ) {
     383                update_user_meta( $user_id, '_new_email', get_option( $user_id . '_new_email' ) );
     384                delete_option( $user_id . '_new_email' );
     385        }
     386}
     387 No newline at end of file