Magento 2: Set order history page as default after login

override account controller as like below.

Vendor\Module\etc\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">       
   <preference for="Magento\Customer\Controller\Account\Index" type="Vendor\Module\Controller\Account\ExtendIndex" /> 
</config>

Then, Vendor\Module\Controller\Account\ExtendIndex.php

<?php
 namespace Vendor\Module\Controller\Account;
 class ExtendIndex extends \Magento\Customer\Controller\Account\Index
 {
   public function execute()
  {
    $resultRedirect = $this->resultRedirectFactory->create();
    $resultRedirect->setPath('sales/order/history');
    return $resultRedirect;
  }
}

I hope this will help you!!


Override the LoginPost controller and set the redirect to history controller in the plugin

Filepath: 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>

Filepath: Vendor/Module/Plugin/LoginPostPlugin.php:

<?php

namespace Vendor\Module\Plugin;

class LoginPostPlugin
{

    public function afterExecute(
        \Magento\Customer\Controller\Account\LoginPost $subject,
        $result)
    {
        $result->setPath('sales/order/history'); 
        return $result;
    }

}

Note:Code tested


You can change My Account link by plugin

Add below code to app/code/Vendor/Module/etc/di.xml

<type name="Magento\Customer\Model\Url">
    <plugin name="custom_links" type="Vendor\Module\Model\Url" sortOrder="1" />
</type>

app/code/Vendor/Module/Model/Url.php

<?php

namespace Vendor\Module\Model;

use Magento\Framework\UrlInterface;

class Url
{
    /**
     * @var UrlInterface
     */
    protected $urlBuilder;


    /**
     * @param UrlInterface $urlBuilder
     */
    public function __construct(
        UrlInterface $urlBuilder
    ) {
        $this->urlBuilder = $urlBuilder;
    }

    public function afterGetAccountUrl(\Magento\Customer\Model\Url $subject, $result)
    {
        return $this->urlBuilder->getUrl('sales/order/history');
    }
}