[joomla] Redirect to a link, after logging in
Sasa Rakic - Gmail
rakics at gmail.com
Mon Nov 14 12:44:43 EST 2011
Dear Julio,
In php file of login form:
if (!isset($FORM["redirect_url"]))
{
if (isset($SERVER["HTTP_REFERER"]) &&
isset($SERVER["PATH_INFO"]) &&
isset($SERVER["QUERY_STRING"]))
{
if ($SERVER["QUERY_STRING"] != "")
{
$FORM["redirect_url"] = $SERVER["PATH_INFO"] . "?" .
$SERVER["QUERY_STRING"];
}
else
{
$FORM["redirect_url"] = $SERVER["HTTP_REFERER"];
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In form:
<?php
if (isset($FORM["redirect_url"]))
{
$clsHtmlHidden = new HtmlHidden($clsHtmlForm);
$clsHtmlHidden->setAttribute("name","redirect_url");
$clsHtmlHidden->setAttribute("value",$FORM["redirect_url"]);
echo $clsHtmlHidden->toHtml();
}
?>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am using this code for after login redirect:
$redirectUrl = $cfgSubscriberLogin->getAfterLoginPage();
if (isset($FORM["redirect_url"]))
{
$redirectUrl = $FORM["redirect_url"];
}
else if (isset($SERVER["HTTP_REFERER"]) &&
$SERVER["HTTP_REFERER"] != "")
{
if ($SERVER["QUERY_STRING"] != "")
{
$redirectUrl = $SERVER["PATH_INFO"] . "?" .
$SERVER["QUERY_STRING"];
}
else
{
$redirectUrl = $SERVER["HTTP_REFERER"];
}
}
if (strpos($redirectUrl,"login.php") > 0)
{
$redirectUrl = "profile.update.php";
}
if (strpos($redirectUrl,"?") === FALSE)
{
$redirectUrl .= "?alert_message=Welcome back " .
$item->getValue("first_name");
}
else
{
$redirectUrl .= "&alert_message=Welcome back " .
$item->getValue("first_name");
}
require(dirname(__FILE__) . "/redirect.html");
exit();
<html>
<head>
<title>Redirecting...</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="0;URL=<?php echo $redirectUrl; ?>">
</head>
<body>
<script type="text/javascript" language="JavaScript">
self.document.location.href= "<?php echo $redirectUrl; ?>";
</script>
</body>
</html>
Best regards,
Sasa
-----Original Message-----
From: joomla-bounces at lists.nyphp.org [mailto:joomla-bounces at lists.nyphp.org]
On Behalf Of Julio D Andrade
Sent: Monday, November 14, 2011 6:37 PM
To: joomla at lists.nyphp.org
Subject: [joomla] Redirect to a link, after logging in
Hi all,
Long time reader, first time poster.
I need some help figuring out how to redirect site members to a page, after
login. Specifically, when you give out a link to something like:
http://members.poweroptions.org/news/newsletters/22-fall-2011-newsletter
If a member follows this link, and the member is NOT logged into the site,
they will be asked to login. After a user is logged in, they are taken to
the home page, NOT the page they were being directed to in the first place.
My client wants to redirect to the correct, after login, automatically. Is
there way to do this? I tried using: Advanced Login Redirect on 404. It
worked for a while, but now it's not working at all.
Please help.
Thanks,
Julio
_______________________________________________
New York PHP SIG: Joomla! Mailing List
http://lists.nyphp.org/mailman/listinfo/joomla
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
More information about the Joomla
mailing list