Index: advuser.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advuser/advuser.module,v
retrieving revision 1.14.2.7.2.5
diff -u -p -r1.14.2.7.2.5 advuser.module
--- advuser.module	8 Apr 2010 22:16:24 -0000	1.14.2.7.2.5
+++ advuser.module	10 Apr 2010 16:04:02 -0000
@@ -226,15 +226,36 @@ function advuser_user_update($edit, $use
 
 /** 
  * hook_user implementation  
+ *
+ * On 'form' (indicates user edit form) save the account data in a static cache.
+ * On 'insert' call the registration notification function.
+ * On 'after_update' call the profile update notification function.
  */
-function advuser_user($type, &$edit, &$user, $category = NULL) {
+function advuser_user($type, &$edit, &$account, $category = NULL) {
+  static $account_before_edit;
   $return = NULL;
   switch ($type) {
+    case 'form': {
+      // Need to remove the form identification data!
+      // Why does it need to be stored in the data serialized array?!
+      $account_before_edit = $account;
+      $account_before_edit->form_build_id = '';
+      $account_before_edit->data = unserialize($account->data);
+      unset ($account_before_edit->data['form_build_id']);
+    } break;
     case 'insert': {
-      $return = advuser_user_insert($edit, $user, $category);
+      $return = advuser_user_insert($edit, $account, $category);
     } break;
     case 'after_update': {
-      $return = advuser_user_update($edit, $user, $category);
+      // Need to remove the form identification data!
+      // Why does it need to be stored in the data serialized array?!
+      $account_after_edit = $account;
+      $account_after_edit->form_build_id = '';
+      $account_after_edit->data = unserialize($account->data);
+      unset ($account_after_edit->data['form_build_id']);
+      if ($account_after_edit != $account_before_edit) {
+        $return = advuser_user_update($edit, $account, $category);
+      }
     } break;
   }
   return $return;
