There is no quick, simple, easy hack to this. However, it was built-in to XOOPS to allow module developers to do that, but it requires the module developer to set a particular variable before redirecting.
The function is redirect_header found in the include/functions.php file:
the passed variable $url is the one you are looking for. Realistically it should pickup the referring URL if none is passed. Unfortunately a lot of modules don't use this very well and just give you the home "index.php" page as passed. Sloppy, but done a lot
So, you'll have to find the instance in the code that does this redirect_header and then pull the current URL to pass as the $url.
Clear as mud?
BTW, many folk just add a login area to the theme and the URL ($url) that is passed in the form is the current URL. That way it times them right back to where they were. That code can be found on this site, too, of course, and is in a couple of the programmatic themes.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill