I am using JomSocial on my site, which is a community-type plugin for Joomla!. Their login module only redirects people to their profile page. What I want is to redirect them to the last page they were on.
However, when someone logs in for the first time, they will be logging in from a page that has an activation token in the URL. If you try to redirect back to a URL with a token in it, the user will either get an error message or a blank page.
What I've tried to do is use the Stripos function to find "activate-account/?activation=" in the URL. If it finds that, I want it to redirect the user to their profile. If it doesn't find that, I want the user redirected back to the originating page... make sense? I believe the problem is that the Stripos function never seems to find "activate-account/?activation" in the URL, so it always redirects back to the originating page. Here's the code I have so far. If there is a better way to code this redirect, let me know, I am definitely open to options. Any help is greatly appreciated.
function getHelloMeLoginHTML($params, $type, $user)
{
$findme = 'activate-account/?activation=';
$mystring1 = $uri;
$pos1 = stripos($mystring1, $findme);
$uri = JFactory::getURI();
if ($pos1 === false) {
$uri = $uri->toString(array('path', 'query', 'fragment'));
$uri = base64_encode($uri);
}
if ($pos1 !== false) {
$uri = CRoute::_('index.php?option=com_community&view=profile' , false );
$uri = base64_encode($uri);
$html = '';
}