diff --git a/user/edit.php b/user/edit.php index 0c981262230..1d6f72c8bd9 100644 --- a/user/edit.php +++ b/user/edit.php @@ -222,9 +222,18 @@ } if (isset($USER->newadminuser)) { unset($USER->newadminuser); - redirect("$CFG->wwwroot/", get_string("changessaved")); + redirect("$CFG->wwwroot/", get_string('changessaved')); + } + if (!empty($SESSION->wantsurl)) { // User may have been forced to edit account, so let's + // send them to where they wanted to go originally + $wantsurl = $SESSION->wantsurl; + $SESSION->wantsurl = ''; // In case unset doesn't work as expected + unset($SESSION->wantsurl); + redirect($wantsurl, get_string('changessaved')); + } else { + redirect("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", + get_string("changessaved")); } - redirect("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", get_string("changessaved")); } else { redirect("$CFG->wwwroot/$CFG->admin/user.php", get_string("changessaved")); } diff --git a/user/view.php b/user/view.php index 355c9777dab..df8b5b58325 100644 --- a/user/view.php +++ b/user/view.php @@ -9,11 +9,6 @@ $enable = optional_param('enable', ''); // enable email $disable = optional_param('disable', ''); // disable email - if (!empty($SESSION->wantsurl)) { - $wantsurl = $SESSION->wantsurl; - unset($SESSION->wantsurl); - redirect($wantsurl); - } if (empty($id)) { // See your own profile by default require_login();