Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.74
diff -u -p -r1.74 user.pages.inc
--- modules/user/user.pages.inc	11 Jul 2010 22:14:28 -0000	1.74
+++ modules/user/user.pages.inc	27 Aug 2010 06:57:35 -0000
@@ -302,13 +302,12 @@ function user_profile_form_submit($form,
   // Remove unneeded values.
   form_state_values_clean($form_state);
 
-  entity_form_submit_build_entity('user', $account, $form, $form_state);
-
   // Populate $edit with the properties of $account, which have been edited on
   // this form by taking over all values, which appear in the form values too.
-  $edit = array_intersect_key((array) $account, $form_state['values']);
+  $edit = array_intersect_key($form_state['values'], (array) $account);
 
   user_save($account, $edit, $category);
+  entity_form_submit_build_entity('user', $account, $form, $form_state);
   $form_state['values']['uid'] = $account->uid;
 
   if ($category == 'account' && !empty($edit['pass'])) {
