Advertisement
Redirect after password reset
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Dec 21, 2008 12:21 pm
Redirect after password reset
Hello,
A strange request but due the nature of the way I am using my joomla install I need the redirect after a user resets their password to go back 3 pages to the original url (which is not fixed) that they where trying to visit. Can anyone think of a way to do this, it is basically the same functionality you get when you try to log in using the login component and you use the wrong username/password when you eventually get it right it will take you back to the original page.
Any ideas to point me into the right direction?
Many Thanks
David
A strange request but due the nature of the way I am using my joomla install I need the redirect after a user resets their password to go back 3 pages to the original url (which is not fixed) that they where trying to visit. Can anyone think of a way to do this, it is basically the same functionality you get when you try to log in using the login component and you use the wrong username/password when you eventually get it right it will take you back to the original page.
Any ideas to point me into the right direction?
Many Thanks
David
Advertisement
- ionut
- Joomla! Ace
- Posts: 1264
- Joined: Thu May 27, 2010 1:00 pm
- Location: EU
Re: Redirect after password reset
How do you send the user from the original page to the reset page? Do you have a link on all pages that points to registration page? Can you give more examples on what you are trying to do, or maybe to even give a link to your website so we can have a better idea on what you are trying to achieve.
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Dec 21, 2008 12:21 pm
Re: Redirect after password reset
Hi,
So basically if someone registers I use redirect on login to make sure that they auto login and redirect back to the referrer page. then I have used Ajax register to ensure that no-one can submit an incorrect form on the register page to ensure that the referrer page is the previous page but this is not possible with the reset page as there is three links to go through before you finish. See the link below and register then reset the password if you like.
http://hhost1.com/h2g/index.php/aquilareg
So basically if someone registers I use redirect on login to make sure that they auto login and redirect back to the referrer page. then I have used Ajax register to ensure that no-one can submit an incorrect form on the register page to ensure that the referrer page is the previous page but this is not possible with the reset page as there is three links to go through before you finish. See the link below and register then reset the password if you like.
http://hhost1.com/h2g/index.php/aquilareg
- ionut
- Joomla! Ace
- Posts: 1264
- Joined: Thu May 27, 2010 1:00 pm
- Location: EU
Re: Redirect after password reset
I have done all these, but you didn't told me why exactly you need this 3 steps back solution. Since after reset password step I'm being redirected to the login page which seems to be the right solution.
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Dec 21, 2008 12:21 pm
Re: Redirect after password reset
Hello,
Thank you for looking into this the issue is it needs to go back to the original link (http://hhost1.com/h2g/index.php/aquilareg) and not the login component (the original link uses login module) otherwise when you log in you are redirected to a fixed page (currently index.php) and the nature of this site means that you are then lost because there is no menu structure or way to click to the original link. This is because each link is effectively a self serving white label site that gets e-mailed to people.
Does that make sense? I know this is a really odd way of doing things I have never had to build a site like it before!
Thank you for looking into this the issue is it needs to go back to the original link (http://hhost1.com/h2g/index.php/aquilareg) and not the login component (the original link uses login module) otherwise when you log in you are redirected to a fixed page (currently index.php) and the nature of this site means that you are then lost because there is no menu structure or way to click to the original link. This is because each link is effectively a self serving white label site that gets e-mailed to people.
Does that make sense? I know this is a really odd way of doing things I have never had to build a site like it before!
- ionut
- Joomla! Ace
- Posts: 1264
- Joined: Thu May 27, 2010 1:00 pm
- Location: EU
Re: Redirect after password reset
So, try this way. On your server locate
Make sure you create a backup for this file.
Inside this file, search for "public function complete" and go to the last part of code
Here replace this part of code with
This should work. The only minus is that in case of Joomla update it might overwrite this file, so you'll need again to make this change.
Code: Select all
<joomla root>/components/com_users/controllers/reset.php
Inside this file, search for "public function complete" and go to the last part of code
Code: Select all
// Complete succeeded.
// Get the route to the next page.
$itemid = UsersHelperRoute::getLoginRoute();
$itemid = $itemid !== null ? '&Itemid='.$itemid : '';
$route = 'index.php?option=com_users&view=login'.$itemid;
// Proceed to the login form.
$message = JText::_('COM_USERS_RESET_COMPLETE_SUCCESS');
$this->setRedirect(JRoute::_($route, false), $message);
return true;
Code: Select all
// Complete succeeded.
// Get the route to the next page.
$route = 'http://hhost1.com/h2g/index.php/aquilareg';
$message = JText::_('COM_USERS_RESET_COMPLETE_SUCCESS');
$this->setRedirect( $route, $message);
return true;
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Dec 21, 2008 12:21 pm
Re: Redirect after password reset
You are an absolute hero! That did exactly what I needed thank you so much. I have a couple of other core changes on this site and have them documented for updates so thats no issue.
Really appreciate you taking the time to help me here!
Really appreciate you taking the time to help me here!
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Dec 21, 2008 12:21 pm
Re: Redirect after password reset
Ahh sorry I just got a little too excited there and didn't read the code is there any way of changing it from the actual absolute url to a dynamic redirect of the referrer url because it will not alway be
http://hhost1.com/h2g/index.php/aquilareg
It could be any url?
Sorry to keep asking I will take a look myself as well.
http://hhost1.com/h2g/index.php/aquilareg
It could be any url?
Sorry to keep asking I will take a look myself as well.
- ionut
- Joomla! Ace
- Posts: 1264
- Joined: Thu May 27, 2010 1:00 pm
- Location: EU
Re: Redirect after password reset
So, let me understand, you will have more pages like http://hhost1.com/h2g/index.php/xxxxx and you want based on the page to have your user redirected to proper page?
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Dec 21, 2008 12:21 pm
Re: Redirect after password reset
Yes this is what I am trying to achieve, can you think of a way to do it? It is in the same way the that the login component works when you log in successfully it takes you back to the page you where trying to visit.
- ionut
- Joomla! Ace
- Posts: 1264
- Joined: Thu May 27, 2010 1:00 pm
- Location: EU
Re: Redirect after password reset
Let's try this way. It's more code hacking but I hope it will do the job for you. Remember to backup each file we'll affect.
Go to
Inside function populateState() add the following code:
This will keep in session the actual referer url when the user tries to reset the password.
After this inside the file you have already made the modifications (/components/com_users/controllers/reset.php), instead of the code I have provided first time, write this code
Make this modifications and let me know if it works.
Go to
Code: Select all
<joomla root>/components/com_users/models/reset.php
Code: Select all
$referer = JFactory::getApplication()->getUserState('site.referer');
if (empty($referer)) {
$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
JFactory::getApplication()->setUserState('site.referer', $referer);
}
After this inside the file you have already made the modifications (/components/com_users/controllers/reset.php), instead of the code I have provided first time, write this code
Code: Select all
// Complete succeeded.
// Get the route to the next page.
$referer = JFactory::getApplication()->getUserState('site.referer');
JFactory::getApplication()->setUserState('site.referer', null);
$message = JText::_('COM_USERS_RESET_COMPLETE_SUCCESS');
$this->setRedirect( $referer, $message);
return true;
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Dec 21, 2008 12:21 pm
Re: Redirect after password reset
Hi, That seems to have cracked it! You are an absolute genius once again thank you for taking the time to help!!
- ionut
- Joomla! Ace
- Posts: 1264
- Joined: Thu May 27, 2010 1:00 pm
- Location: EU
Re: Redirect after password reset
You are welcome, I'm glad it worked ![Smiley :)](./images/smilies/icon_smile.gif)
![Smiley :)](./images/smilies/icon_smile.gif)
Advertisement