cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Login section on Magento 2.3

Custom Login section on Magento 2.3

Problem:  I have a link on the home page.
When a customer clicks on the link before login it needs to redirect to the login page
and after the success of the log in the page needs to redirect to an X-URL URL.
Otherwise needs to redirect to X-URL.

I did create a custom

app/code/<vendor>/<module>/view/fromtend/layout/customer_account_create.xml

on my custom module

and  copy the login file and save it inside

 

app/code/<vendor>/<module>/view/fromtend/template/login.phtml

 So currently the login interface is taken from the module.
Then I set a flag Home page link named "raf=true"

then created a hidden input on the login page form and assign the value if "ref=true".

And I did check the "raf" value is true if the page redirect to X-URL otherwise defaults (LoginPost.php).

It is working for me. But

 

The form activities are handled by vendor file (default package file under vendor directory).

How can I resolve this in the proper way?

 

 

 

 

kalathinkal
2 REPLIES 2

Re: Custom Login section on Magento 2.3

Hi @vipinsimpl4aed ,

 

You need not to create new login module for this requirment, You can set the HREF for the link on condition basis:

if($this->_customerSession->isLoggedIn()){
       // Redirect to X-URL
} else{
       // Redirect to Login Page
}

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Re: Custom Login section on Magento 2.3

This condition is helped for switching the link redirection.

if($this->_customerSession->isLoggedIn()){
// Redirect to X-URL
} else{
// Redirect to Login Page
}

But in else case, how can I redirect to X-URL after complete the login(Only for this situation all other case needs to work default).

 

I did try this https://stackoverflow.com/questions/29654718/how-to-override-controller-in-magento2
But  did not work for me

kalathinkal