{"id":1728,"date":"2021-04-22T12:13:03","date_gmt":"2021-04-22T12:13:03","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/redirect-customer-to-custom-page-after-login-in-magento-2\/"},"modified":"2025-07-16T18:00:05","modified_gmt":"2025-07-16T12:30:05","slug":"redirect-customer-to-custom-page-after-login-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/redirect-customer-to-custom-page-after-login-in-magento-2\/","title":{"rendered":"How to Redirect Customer to Custom Page after Login in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The default\u00a0Magento 2\u00a0redirects a customer to their \u201cMy Account\u201d dashboard section or the previous page once they log in to the store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, not all the default functionalities may be suitable for your modern online store. Fortunately, the Magento CMS is flexible enough to allow the developers to tweak the features and customize them based on the business requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In today\u2019s post, I\u2019ll give the solution for one such similar customization that store owners frequently require.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a customer logs in to your store, it is the prime time when you can redirect their attention to things you want. It is a short time span where you can lure them for engagement or even conversion.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So why not redirect them to your latest products, or best sellers or even some offers and discounts that you may be offering in your store at once when they log in!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can redirect your customers to some appointment page if you have one and your business requires customers to book an appointment. Or, you can simply redirect them to any custom CMS page that you want them to have a look at.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It can be done using the below solution to&nbsp;<em><strong>redirect customer to custom page after login in Magento 2<\/strong><\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Redirect Customer to Custom Page after Login in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Use below code in&nbsp;<strong>di.xml<\/strong>&nbsp;file at&nbsp;<strong><strong>Vendor\/Extension\/etc\/frontend<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">\n    &lt;type name=\"\\Magento\\Customer\\Controller\\Account\\LoginPost\">\n        &lt;plugin name=\"redirect_custom_url\" type=\"\\Vendor\\Extension\\Plugin\\RedirectCustomUrl\" sortOrder=\"1\"\/>\n    &lt;\/type>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Paste the below code in&nbsp;<strong>RedirectCustomUrl.php<\/strong>&nbsp;file at&nbsp;<strong><strong>Vendor\/Extension\/Plugin<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n \nnamespace Vendor\\Extension\\Plugin;\n \nclass RedirectCustomUrl\n{\n \n    public function afterExecute(\n        \\Magento\\Customer\\Controller\\Account\\LoginPost $subject,\n        $result)\n    {\n        $customUrl = 'sales\/order\/history';\n        $result->setPath($customUrl);\n        return $result;\n    }\n \n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use the path of your required page instead of \u2018sales\/order\/history\u2019 in $customUrl variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Done!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the method with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default\u00a0Magento 2\u00a0redirects a customer to their \u201cMy Account\u201d dashboard section or the previous page once they log in to the store. However, not all&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1728","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1728"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1728\/revisions"}],"predecessor-version":[{"id":18106,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1728\/revisions\/18106"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}