How to Redirect Users After Login to Previous/Referrer Page
By default, when users log in to WordPress via the default login form, they are redirected to the admin dashboard.
In this tutorial, we will learn how to redirect users back to the previous page (or referrer page) they were viewing after they log in. This is particularly useful in membership sites or news/media blogs where users create or register accounts.
This doesn’t only work for the default WordPress login page, but also on the custom login forms of various forms and membership plugins we support, including that of WooCommerce, Gravity Forms, WPForms, LifterLMS, Easy Digital Downloads, WP User Frontend, LearnDash, MemberPress, MemberMouse, Restrict Content Pro, Paid Memberships Pro, ProfilePress, LearnPress, Ultimate Member, WishList Member, WP User Manager, Tutor LMS, Theme My Login, User Registration (WPEverest), Polylang, WPML.
Redirecting to Previous Page after Login
To achieve this, follow the guide below. Don’t forget you need to first install and activate the LoginWP plugin.
Go to the Redirection settings page via LoginWP >> Redirections.
For Specific Users
If you want to only redirect specific users back to the previous page they were on or the referer page, create a rule for them and set {{previous_page}}
as the Login URL.
For All Users
To apply the rule to every user or the other users that don’t meet your login redirect rules, use the “All Other Users” section.
Don’t forget to save your changes.