Login Redirect
Permalink
Concrete Version 5.7.5.13
I searched the forum for this and cannot find the answer.
I am trying to do a redirect back to the page the user logs in from. I have the Community Store installed and would love the user to be about the login in and not be redirected back to the Home Page, instead the page they clicked login from.
I searched the forum for this and cannot find the answer.
I am trying to do a redirect back to the page the user logs in from. I have the Community Store installed and would love the user to be about the login in and not be redirected back to the Home Page, instead the page they clicked login from.
I want the exact same thing for customers. Used to work with 8.3.1, but will NOT work with 8.3.2?
Try:
Or:
Try:
Or:
<a href="<?=$this->url('/login', 'forward', $c->getCollectionID())?>"> <?php echo t('Sign in')?></a>
In all version of Concrete5 including 5.7.5.13 and 8.3.1 (not tested in 8.3.2) this works for me:
For this to work you have to make sure in your dashboard under dashboard/system/registration/postlogin, you set yur redirection option to "homepage"
Of course there is no way to redirect someone who goes directly to the login page instead of clicking on the link
<?php $page = Page::getCurrentPage(); $loginurl = URL::to('/login', 'forward', $page->getCollectionID()); ?> <a href="<?php echo $loginurl; ?>" >Click here to login</a>
For this to work you have to make sure in your dashboard under dashboard/system/registration/postlogin, you set yur redirection option to "homepage"
Of course there is no way to redirect someone who goes directly to the login page instead of clicking on the link
None of the above options work with 8.3.2?
@Steevb I just checked and it doesn't work in 8.3.2 because there is a typo. If yu want it to work modify the file concrete\src\User\PostLoginLocation.php line 118.
There is an error where $$normalized should be $normalized (notice the extra $)
This has already been corrected in the next version by the way
There is an error where $$normalized should be $normalized (notice the extra $)
This has already been corrected in the next version by the way
Bloody brilliant, thanks.
That is awesome!
Now though, I tried to use your code with a small change:
Then discovered that the register.php has an extra page, so it doesn't quite work. If I place it in the register.php page it puts me back on the registration form. My test site is broken, so I don't want to experiment with trying to get it working on the live site.
Now though, I tried to use your code with a small change:
<?php $page = Page::getCurrentPage(); $regurl = URL::to('/register', 'forward', $page->getCollectionID()); ?> <a href="<?php echo $regurl; ?>" >Click here to login</a>
Then discovered that the register.php has an extra page, so it doesn't quite work. If I place it in the register.php page it puts me back on the registration form. My test site is broken, so I don't want to experiment with trying to get it working on the live site.
this should not be on the register page. This is a link that should be on any other page where the user might be. They would then click on the link to go to the registration page that will be informed to redirect them to the original page after registration.
Putting it on the register page serves no purpose since they're already there.
Or maybe I misunderstood you?
Putting it on the register page serves no purpose since they're already there.
Or maybe I misunderstood you?
I am using Community Store and on the checkout page there is a Register link, if the user goes to check out and decided to register it would be nice if they could end up at the checkout page then.
https://www.mdius.com/switches/clamps-clips...
Add that to the cart and click checkout to see what I mean, if you'd like.
https://www.mdius.com/switches/clamps-clips...
Add that to the cart and click checkout to see what I mean, if you'd like.
You know, I could put a link to the cart at the bottom of the page I suppose. Then it would be a simple way to either go the the home page or cart.
Unless you got a better, more clever idea.
Unless you got a better, more clever idea.
from what i can see you have a customized registration page.
try this:
In your register.php single page, where you have
modify like this:
it will redirect you to the page where you were before clicking that register link
Reminder: For this to work you have to make sure in your dashboard under dashboard/system/registration/postlogin, you set your redirection option to "homepage"
try this:
In your register.php single page, where you have
modify like this:
<?php switch ($registerSuccess) { case "registered": if (!empty($rcID)) { $rc = Page::getByID($rcID); if ($rc instanceof Page && !$rc->isError()) { $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication(); $navigation = $app->make('helper/navigation'); $rUrl = $navigation->getLinkToCollection($rc); $r = new RedirectResponse($rUrl); $r->send(); exit; } } ?> <p><strong><?php echo $successMsg ?></strong><br/><br/>
Viewing 15 lines of 18 lines. View entire code block.
it will redirect you to the page where you were before clicking that register link
Reminder: For this to work you have to make sure in your dashboard under dashboard/system/registration/postlogin, you set your redirection option to "homepage"
You are amazing!
Worked perfectly!
Thank you so very much!
Worked perfectly!
Thank you so very much!
You are very welcome :)
Life saver! thanks for this one..
This used to work for me, too. However, the redirect does not work in 8.4 anymore. The forward link is generated including the correct page id: /login/forward/220, yet the user is still being redirect to the homepage.
Did I overlook any changes to the forward behavior? Anyone experiencing the same?
Did I overlook any changes to the forward behavior? Anyone experiencing the same?
Working 4 me, which code snippet r u using?
Hi Steevb,
I used the following code provided by mnakalay (thank you!) and I can confirm it works just fine with a clean install of concrete5 8.4.1:
I am now investigating the particular server setup and customized theme that has been used. Redirect to "homepage" has been set.
I used the following code provided by mnakalay (thank you!) and I can confirm it works just fine with a clean install of concrete5 8.4.1:
<?php $page = Page::getCurrentPage(); $loginurl = URL::to('/login', 'forward', $page->getCollectionID()); ?> <a href="<?php echo $loginurl; ?>" >Click here to login</a>
I am now investigating the particular server setup and customized theme that has been used. Redirect to "homepage" has been set.
For this to work you have to make sure in your dashboard under dashboard/system/registration/postlogin, you set your redirection option to "homepage"
As it is, I think you'd need to customise the login page. Hopefully the redirect URL would be in $_SERVER['HTTP_REFERER'], although you probably shouldn't get at it that way.