Integrate update_profile_email() into user-edit.php. see #11644

git-svn-id: http://svn.automattic.com/wordpress/trunk@12928 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-02-02 18:00:45 +00:00
parent 5922f7e2c4
commit 8caab555bd
2 changed files with 15 additions and 21 deletions

View File

@ -266,23 +266,6 @@ All at ###SITENAME###
}
add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
function update_profile_email() {
global $current_user, $wpdb;
if ( isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
$new_email = get_option( $current_user->ID . '_new_email' );
if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
$user->ID = $current_user->ID;
$user->user_email = wp_specialchars( trim( $new_email[ 'newemail' ] ) );
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( get_object_vars( $user ) );
delete_option( $current_user->ID . '_new_email' );
wp_redirect( add_query_arg( array('updated' => 'true'), admin_url( 'profile.php' ) ) );
die();
}
}
}
function send_confirmation_on_profile_email() {
global $errors, $wpdb, $current_user, $current_site;
if ( ! is_object($errors) )
@ -803,10 +786,6 @@ function choose_primary_blog() {
<?php
}
if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) ) {
add_action( 'admin_init', 'update_profile_email' );
}
function stripslashes_from_options( $blog_id ) {
global $wpdb;

View File

@ -65,6 +65,21 @@ function use_ssl_preference($user) {
if ( is_multisite() && !defined( "EDIT_ANY_USER" ) && !is_super_admin() && $user_id != $current_user->ID )
wp_die( __( 'You do not have permission to edit this user.' ) );
// 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' ] ) {
$user->ID = $current_user->ID;
$user->user_email = wp_specialchars( trim( $new_email[ 'newemail' ] ) );
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( get_object_vars( $user ) );
delete_option( $current_user->ID . '_new_email' );
wp_redirect( add_query_arg( array('updated' => 'true'), admin_url( 'profile.php' ) ) );
die();
}
}
switch ($action) {
case 'switchposts':