web/wp-admin/user-edit.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    80 
    80 
    81 // Execute confirmed email change. See send_confirmation_on_profile_email().
    81 // Execute confirmed email change. See send_confirmation_on_profile_email().
    82 if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
    82 if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
    83 	$new_email = get_option( $current_user->ID . '_new_email' );
    83 	$new_email = get_option( $current_user->ID . '_new_email' );
    84 	if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
    84 	if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
       
    85 		$user = new stdClass;
    85 		$user->ID = $current_user->ID;
    86 		$user->ID = $current_user->ID;
    86 		$user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
    87 		$user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
    87 		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
    88 		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
    88 			$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
    89 			$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
    89 		wp_update_user( get_object_vars( $user ) );
    90 		wp_update_user( $user );
    90 		delete_option( $current_user->ID . '_new_email' );
    91 		delete_option( $current_user->ID . '_new_email' );
    91 		wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    92 		wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    92 		die();
    93 		die();
    93 	}
    94 	}
    94 } elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
    95 } elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
   137 	if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
   138 	if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
   138 		empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
   139 		empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
   139 }
   140 }
   140 
   141 
   141 if ( !is_wp_error( $errors ) ) {
   142 if ( !is_wp_error( $errors ) ) {
   142 	$redirect = (IS_PROFILE_PAGE ? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
   143 	$redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
   143 	if ( $wp_http_referer )
   144 	if ( $wp_http_referer )
   144 		$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
   145 		$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
   145 	wp_redirect($redirect);
   146 	wp_redirect($redirect);
   146 	exit;
   147 	exit;
   147 }
   148 }
   243 		<th><label for="user_login"><?php _e('Username'); ?></label></th>
   244 		<th><label for="user_login"><?php _e('Username'); ?></label></th>
   244 		<td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>
   245 		<td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>
   245 	</tr>
   246 	</tr>
   246 
   247 
   247 <?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
   248 <?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
   248 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
   249 <tr><th><label for="role"><?php _e('Role') ?></label></th>
   249 <td><select name="role" id="role">
   250 <td><select name="role" id="role">
   250 <?php
   251 <?php
   251 // Get the highest/primary role for this user
   252 // Compare user role against currently editable roles
   252 // TODO: create a function that does this: wp_get_user_role()
   253 // TODO: create a function that does this: wp_get_user_role()
   253 $user_roles = $profileuser->roles;
   254 $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
   254 $user_role = array_shift($user_roles);
   255 $user_role  = array_shift( $user_roles );
   255 
   256 
   256 // print the full list of roles with the primary one selected.
   257 // print the full list of roles with the primary one selected.
   257 wp_dropdown_roles($user_role);
   258 wp_dropdown_roles($user_role);
   258 
   259 
   259 // print the 'no role' option. Make it selected if the user has no role yet.
   260 // print the 'no role' option. Make it selected if the user has no role yet.
   264 ?>
   265 ?>
   265 </select></td></tr>
   266 </select></td></tr>
   266 <?php endif; //!IS_PROFILE_PAGE
   267 <?php endif; //!IS_PROFILE_PAGE
   267 
   268 
   268 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
   269 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
   269 <tr><th><label for="role"><?php _e('Super Admin'); ?></label></th>
   270 <tr><th><?php _e('Super Admin'); ?></th>
   270 <td>
   271 <td>
   271 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) ) : ?>
   272 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?>
   272 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
   273 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
   273 <?php else : ?>
   274 <?php else : ?>
   274 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
   275 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
   275 <?php endif; ?>
   276 <?php endif; ?>
   276 </td></tr>
   277 </td></tr>
   421 </div>
   422 </div>
   422 <?php
   423 <?php
   423 break;
   424 break;
   424 }
   425 }
   425 ?>
   426 ?>
   426 <script type="text/javascript" charset="utf-8">
   427 <script type="text/javascript">
   427 	if (window.location.hash == '#password') {
   428 	if (window.location.hash == '#password') {
   428 		document.getElementById('pass1').focus();
   429 		document.getElementById('pass1').focus();
   429 	}
   430 	}
   430 </script>
   431 </script>
   431 <?php
   432 <?php