How to redirect user-login.php to specific page

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