WordPress.org

Make WordPress Core

Ticket #23358: 23358.dff

File 23358.dff, 4.3 KB (added by MikeHansenMe, 8 years ago)

First pass at switching to user_meta

Line 
1Index: wp-admin/user-edit.php
2===================================================================
3--- wp-admin/user-edit.php      (revision 25154)
4+++ wp-admin/user-edit.php      (working copy)
5@@ -80,7 +80,7 @@
6 
7 // Execute confirmed email change. See send_confirmation_on_profile_email().
8 if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
9-       $new_email = get_option( $current_user->ID . '_new_email' );
10+       $new_email = get_user_meta( $current_user->ID, '_new_email' );
11        if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
12                $user = new stdClass;
13                $user->ID = $current_user->ID;
14@@ -88,31 +88,31 @@
15                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
16                        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
17                wp_update_user( $user );
18-               delete_option( $current_user->ID . '_new_email' );
19-               wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
20+               delete_user_meta( $current_user->ID, '_new_email' );
21+               wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) );
22                die();
23        }
24 } elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
25-       delete_option( $current_user->ID . '_new_email' );
26+       delete_user_meta( $current_user->ID, '_new_email' );
27        wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
28        die();
29 }
30 
31-switch ($action) {
32+switch ( $action ) {
33 case 'update':
34 
35-check_admin_referer('update-user_' . $user_id);
36+check_admin_referer( 'update-user_' . $user_id );
37 
38-if ( !current_user_can('edit_user', $user_id) )
39-       wp_die(__('You do not have permission to edit this user.'));
40+if ( !current_user_can( 'edit_user', $user_id ) )
41+       wp_die( __( 'You do not have permission to edit this user.' ) );
42 
43 if ( IS_PROFILE_PAGE )
44-       do_action('personal_options_update', $user_id);
45+       do_action( 'personal_options_update', $user_id );
46 else
47-       do_action('edit_user_profile_update', $user_id);
48+       do_action( 'edit_user_profile_update', $user_id );
49 
50 if ( !is_multisite() ) {
51-       $errors = edit_user($user_id);
52+       $errors = edit_user( $user_id );
53 } else {
54        $user = get_userdata( $user_id );
55 
56@@ -335,10 +335,10 @@
57        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
58        <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" />
59        <?php
60-       $new_email = get_option( $current_user->ID . '_new_email' );
61+       $new_email = get_user_meta( $current_user->ID, '_new_email' );
62        if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
63        <div class="updated inline">
64-       <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>
65+       <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>
66        </div>
67        <?php endif; ?>
68        </td>
69Index: wp-admin/includes/ms.php
70===================================================================
71--- wp-admin/includes/ms.php    (revision 25154)
72+++ wp-admin/includes/ms.php    (working copy)
73@@ -233,7 +233,7 @@
74 
75                if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
76                        $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
77-                       delete_option( $current_user->ID . '_new_email' );
78+                       delete_user_meta( $current_user->ID, '_new_email' );
79                        return;
80                }
81 
82@@ -242,7 +242,7 @@
83                                'hash' => $hash,
84                                'newemail' => $_POST['email']
85                                );
86-               update_option( $current_user->ID . '_new_email', $new_user_email );
87+               update_user_meta( $current_user->ID, '_new_email', $new_user_email );
88 
89                $content = apply_filters( 'new_user_email_content', __( "Dear user,
90