* @since Moodle 3.2
*/
public function user_signup_with_confirmation($user, $notify=true, $confirmationurl = null) {
- global $CFG, $DB;
+ global $CFG, $DB, $SESSION;
require_once($CFG->dirroot.'/user/profile/lib.php');
require_once($CFG->dirroot.'/user/lib.php');
// Save any custom profile field information.
profile_save_data($user);
+ // Save wantsurl against user's profile, so we can return them there upon confirmation.
+ if (!empty($SESSION->wantsurl)) {
+ set_user_preference('auth_email_wantsurl', $SESSION->wantsurl, $user);
+ }
+
// Trigger event.
\core\event\user_created::create_from_userid($user->id)->trigger();
* @param string $confirmsecret
*/
function user_confirm($username, $confirmsecret) {
- global $DB;
+ global $DB, $SESSION;
$user = get_complete_user_data('username', $username);
if (!empty($user)) {
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
+
+ if ($wantsurl = get_user_preferences('auth_email_wantsurl', false, $user)) {
+ // Ensure user gets returned to page they were trying to access before signing up.
+ $SESSION->wantsurl = $wantsurl;
+ unset_user_preference('auth_email_wantsurl', $user);
+ }
+
return AUTH_CONFIRM_OK;
}
} else {