Redirecting to second last visited URL

20 Views Asked by At

I'm a newbie to WordPress. Tried searching around a bit but couldn't find any solution to my problem.

I am using Ultimate Member for my login and registration requirements.

When users login, I am able to redirect them to the previously visited URL with $_SERVER['HTTP_REFERER'].

However for my registration page, it is hyperlinked (referred from) from my login page, so, using $_SERVER['HTTP_REFERER'] redirects me back to my login page. I need a workaround to get to the second last page.

Ultimate member provides the below code to redirect after registration

add_action( 'um_registration_complete', 'my_function' ,1 );
my_function($user_id){
wp_redirect('Need to be able get the second last visited URL'); exit;
}

I tried setting a cookie of the previous url on all pages except the registration page but even that didn't work.

0

There are 0 best solutions below