diff --git a/mod/regmod.php b/mod/regmod.php
index 49a7194934..932b109ebc 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -4,6 +4,8 @@
function regmod_content(&$a) {
+ $_SESSION['return_url'] = $a->cmd;
+
if(! local_user()) {
notice( t('Please login.') . EOL);
$o .= '
' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);