**Disclaimer: This post is about the JomSocial login module, HelloMe. I posted this on JomSocial's site and the crew over there says my question is not supported by their terms. So they moved
my thread to another sub-forum and it has sat there for over a week, unanswered.
That said, I need some help coding up a redirect for JomSocial's HelloMe module. Out of the box, it always redirects people to their Profile page. What I would like is for the user to be redirected back the their originating page... the page they logged in from. However, there is one catch. 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, it will cause problems for the user... either an error message or a blank page.
I am not a PHP coder, but here's what I've got so far. Basically, I used 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?
Code:
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 = '';
}
The redirect to originating page part works fine, but it does not redirect properly from an account activation URL.
The code used to redirect the user to their profile was written by the folks at JomSocial, so I believe the problem lies with the if statement, or the stripos function.
Any help solving this would be greatly appreciated. TIA!