How to redirect a subscriber back to the page they came from after login or subscribing

After Subscribing behavior

If you are looking for a way to send a user back to the page they came from after subscribing, we have an add-on for that: Registration Redirect.

After Login behavior

We have the Leaky Paywall - Login Redirect add-on available to redirect subscribers to the the article they were reading.

Other options

Static URL

To set a custom redirect URL for the login form, you can use the login_redirect_url attribute on the shortcode itself.  For example, the screenshot below will send the user back to the homepage after they log in.

Cache

If you are using a caching plugin, or a host that uses page caching like WP Engine, make sure to turn off caching for your login page. Otherwise, this code will not work.

If your cache plugin has an exclude option, enter your login page URL.

If your cache plugin has Browser Static File Caching settings, be sure to disable or set the expiration time to 0.

Dynamic URL

When the user hits the article limit, he is prompted to login. By default, this login sends the user to the profile page, or URL set with the login_redirect_url attribute, but not the page they came from. 

Here’s a snippet that will send the user back to the page they were on when they clicked the login link.

Note: If you are using a caching plugin, or a host that uses page caching like WP Engine, make sure to turn off caching for your login page. Otherwise, this code will not work. If your cache plugin has Browser Static File Caching settings, be sure to disable or set the expiration time to 0.

Still need help? Contact Us Contact Us