mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 12:14:25 +00:00
Multisite: Switch to a usermeta key for email confirmation.
To prevent inconsistent data across sites in a network the new email address is now stored in usermeta. Adds visual feedback for the case when an update has failed. All existing options will be removed on a database upgrade. Props MikeHansenMe, kovshenin, jeremyfelt, ocean90. Fixes #23358. git-svn-id: https://develop.svn.wordpress.org/trunk@36679 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -82,20 +82,23 @@ if ( is_multisite()
|
||||
|
||||
// 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 && $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' );
|
||||
delete_user_meta( $current_user->ID, '_new_email' );
|
||||
wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
|
||||
die();
|
||||
}
|
||||
@@ -181,6 +184,13 @@ include(ABSPATH . 'wp-admin/admin-header.php');
|
||||
<?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; ?>
|
||||
@@ -383,7 +393,7 @@ if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_c
|
||||
<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
|
||||
|
||||
Reference in New Issue
Block a user