PHP Code:
$pageurl = get_page_url(true);
You'll need to pass the "$pageurl" variable to the build_user_area() function, but this will not work, because you are in "private" page. You'll lose variable under "login", since your redirects flow is as follows:
Code:
redirect submit redirect
[ private ] ---------> [ login ] ----------> [ accounts ] ------> [ private ]
The simplest thing you can do is to store your redirection url in a session, then call it under build_user_area() function.
in private-page:
Code:
$_SESSION['referer'] = get_page_url(true);
in build_user_area() (accounts-page):
Code:
header('Location: ' . htmlspecialchars($_SESSION['referer']));