Redirect customer to custom page after login based on Customer Group in Magento 2 –

Wite Plugin in you,

Like my extension Equltrue_Customerlogin

so di file path will be app/code/Equaltrue/Customerlogin/etc/frontend/di.xml

    <type name="\Magento\Customer\Controller\Account\LoginPost">
        <plugin name="equaltrue_customerlogin_loginpostplugin" type="\Equaltrue\Customerlogin\Plugin\LoginPostPlugin" sortOrder="1" />

On plugin File on location,\


Write the following code:

namespace Equaltrue\Customerlogin\Plugin;
class LoginPostPlugin
    public function afterExecute(
        \Magento\Customer\Controller\Account\LoginPost $subject,
        //-- check group is retail customer or not
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $customerSession = $objectManager->create('Magento\Customer\Model\Session');
        if ($customerSession->isLoggedIn()){
            $groupId = $customerSession->getCustomerGroupId();
            if ($groupId == 3){
        return $result;



Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.