MDL-13811 reworked unsetting of preferences and minor tweaks
[moodle.git] / user / edit.php
index 79814bc..b88fdd0 100644 (file)
         print_error('invaliduserid');
     }
 
-    // Process email change cancellation
-    if ($cancelemailchange) {
-        useredit_load_preferences($user);
-        $user->preference_newemail = null;
-        $user->preference_newemailkey = null;
-        $user->preference_newemailattemptsleft = null;
-        useredit_update_user_preference($user);
-    }
-
-
     // Guest can not be edited
     if (isguestuser($user)) {
         print_error('guestnoeditprofile');
         die;
     }
 
+    // Process email change cancellation
+    if ($cancelemailchange) {
+        cancel_email_update($user->id);
+    }
+
     //load user preferences
     useredit_load_preferences($user);