I would like to have the user redirected to homepage instead of dashboard as soon as he logs in.
Asked
Active
Viewed 64 times
0
-
1https://magento.stackexchange.com/questions/134808/magento-2-redirect-customer-to-custom-page-after-login – Nagaraju Kasa Nov 10 '19 at 04:23
1 Answers
0
Use plugin concept and redirect to magento2 home page after login user successfully.
/Vendor/Module/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="\Magento\Customer\Controller\Account\LoginPost">
<plugin name="vendor_module_loginpostplugin" type="\Vendor\Module\Plugin\LoginPostPlugin" sortOrder="1" />
</type>
</config>
/Vendor/Module/Plugin/LoginPostPlugin.php
<?php
namespace Vendor\Module\Plugin;
class LoginPostPlugin
{
/**
* Change redirect after login to home instead of dashboard.
*
* @param \Magento\Customer\Controller\Account\LoginPost $subject
* @param \Magento\Framework\Controller\Result\Redirect $result
*/
public function afterExecute(
\Magento\Customer\Controller\Account\LoginPost $subject,
$result)
{
$result->setPath('/'); // Change this to what you want
return $result;
}
}
Nagaraju Kasa
- 5,856
- 6
- 53
- 113