How to redirect user-login.php to specific page

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 Steve99 - March 8, 2019

Hi,

On line 18 and 19 in the v1.13 website membership plugin php file you'll find the following:

// After login, user gets redirected to the last page they were on (if defined), the url below, or to /
$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'] = PREFIX_URL.'/yourRedirectAfterLoginPageHere.php';

That sets the page to redirect the user to after login, and you'll want to keep that snippet of code you posted from the login page commented out as you do.

Hope this helps!

Best,
Steve

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