How to redirect user-login.php to specific page

By hellenicvascularsurgery - March 7, 2019

Hi

I assume it is an easy task for experienced users, but unfortunately not for me. In the Website membership I want to redirect to a specific webpage after login. I have inserted the specific url (i.e. https://www........) of the page I want to redirect the user to, instead the "lastUrl" in the user-login.php file (as seen below), but it does not work. It always sends me back to the first page of the website, not even on the last referring page 

// save url of referring page so we can redirect user there after login
  // if (!getPrefixedCookie('lastUrl')) { setPrefixedCookie('lastUrl', @$_SERVER['HTTP_REFERER'] ); }

 Kind regards

Andreas Lazaris

By andreasml - March 9, 2019

Hi Steve

Thank you. I changed the

yourRedirectAfterLoginPageHere.php

to the url I wanted to redirect the user to and it worked!

But, what if i wanted to redirect the user to the last page he/she was on. How will i do it? Is it so by default or should i need to change/add something?

Just to note again that by leaving the default option, 

$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']  = PREFIX_URL.'/';

it redirected user to the first page of the website.

Regards,

Andreas Lazaris

By Steve99 - March 11, 2019

Hi Andreas,

Sure, if you want to redirect the user to the last page they were on (prior to logging in) then simply delete the "//" php comment on this line of code for the login page:

  // save url of referring page so we can redirect user there after login
  if (!getPrefixedCookie('lastUrl')) { setPrefixedCookie('lastUrl', @$_SERVER['HTTP_REFERER'] ); }

Best,
Steve

By andreasml - March 11, 2019

Hi Steve

It was really easy!

Thanks

Andreas