i there any way i can add reffer like, so user can be redirected to that url after login, something like below
http://example.com/customer/account/login?u=product-page-url
i have already set below from admin
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityi there any way i can add reffer like, so user can be redirected to that url after login, something like below
http://example.com/customer/account/login?u=product-page-url
i have already set below from admin
Note: In admin Customer redirect option should be set to "No":As you've already done it as per above image.
Create a new module or in existing module: /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 Here to where you want to redirect
return $result;
}
}
Your case plugin is a better solution And i have tested and showing below code your helpful
I have create the simple module
Custom/Redirect/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="Custom_Redirect_loginpostplugin" type="Custom\Redirect\Plugin\LoginPostPlugin" sortOrder="1" />
</type>
</config>
Custom/Redirect/Plugin/LoginPostPlugin.php
<?php
namespace Custom\Redirect\Plugin;
class LoginPostPlugin
{
public function afterExecute(
\Magento\Customer\Controller\Account\LoginPost $subject,
$result)
{
$result->setPath('YourURL/'); // Change this to what you want
return $result;
}
}
Custom/Redirect/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Custom_Redirect',
__DIR__
);
Thanks.