0

I am using magento 2.1.0 and i am trying to redirect customer to account edit page after login instead of home page of dashboard after login

For this i created one plugin for login post and define that plugin in di.xml

Plugin Code:

<?php

namespace xxxx\xxxx\Plugin;

 class LoginPost
 {

/**
 * @var \Magento\Framework\UrlInterface
 */
protected $url;

/**
 * @param \Magento\Framework\UrlInterface $url
 */
public function __construct(
    \Magento\Framework\UrlInterface $url
)
{
    $this->url = $url;
}

public function afterExecute(
    \Magento\Customer\Controller\Account\LoginPost $subject,
    $resultRedirect
) {
    $resultRedirect->setUrl($this->url->getUrl('customer/account/edit'));
    return $resultRedirect;
}
 }

What i am doing wrong or miss something???

  • I couldn't get this to work either for a long amount of time. Have you tried enabling the Redirect Customer to Account Dashboard after Logging in setting in admin panel under Stores -> Configurations -> Customers -> Customer Configuration? The observer seems to work for me from then on – A. Fletcher Sep 4 at 15:07
1

Can you try the following Code?

protected $resultRedirectFactory;
    public function __construct(
        \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory
    ) {
        $this->resultRedirectFactory = $resultRedirectFactory;
    }
    public function afterExecute($subject, $result)
    {
        /** @var \Magento\Framework\View\Result\Page $resultPage */
        $resultRedirect = $this->resultRedirectFactory->create();
        $resultRedirect->setPath('customer/account/edit');
        return $resultRedirect;
    }
  • no, its also not working – sam Mar 2 '17 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.