You can use the login_redirect
filter to do this. One of the parameters is $request
, which
is the URL the user is coming from
function wpse125952_redirect_to_request( $redirect_to, $request, $user ){
// instead of using $redirect_to we're redirecting back to $request
return $request;
}
add_filter('login_redirect', 'wpse125952_redirect_to_request', 10, 3);
The filter could additionally easily be used for distinguishing redirect destinations by user roles. Take a look at the documentation for a deeper insight into that.
Related Posts:
- Redirect user to original url after login?
- Login redirect to previous page
- Redirect to referring page after logging in
- check first time login only
- How to change the default logout link on WordPress Admin
- How to redirect after login, the working way?
- Password change when the user login first time
- Custom login form redirect to external site
- handling login/logout redirects
- Restrict Access to wp-login.php
- Using `auth_redirect` : keeps asking me to login even when I’m logged in
- Redirect users after first login
- wp-login.php — redirect logged in users to custom URL
- Redirect user after login/registration globally
- Redirect to login page
- You do not have sufficient permissions to access this page
- Redirect user after logout
- how to do logout redirect to current url
- How to redirect user to specific page based on the input password
- How do I redirect a user when he is logged in after clicking on a menu
- How to modify the Register link in the login page?
- Changing “Lost Password Email Link” to custom password reset page
- How to redirect user to a specific page based on username?
- Redirect after password update
- How to redirect user after login to a specific page?
- Redirect Logged In User if page is wp-login.php and $_Get[‘level’] = X
- Redirect when accessing /login when logged in
- How to redirect after login getting a variable from url (for example with the language)
- If User is NOT Logged in and Page ID is not 6 – Redirect to Login
- Redirect to Current Page after Login
- How to include error message on login
- Login redirect problem
- How to redirect on login to a specific page if a specific meta user is empty
- redirect Login problems
- Redirect user to previous page after signup from custom form
- How can I force the user to log in, even if they’re already authenticated?
- User is logged in after Stripe payment, then redirected, but is then logged out again
- Login Redirect – Multiple Scenarios
- WooCommerce – Redirect to a product after login
- Usage of the login_redirect filter
- Login/Register redirect user with message
- Redirect user to original url after login?
- Prevent users from going to wordpress profile after login
- Custom form redirect after login
- Custom redirect user after login based on metadata
- Custom Login Form – Redirect user to login page if not logged in
- Redirection on Custom page
- Redirect user to specific link after login
- Load function with login_redirect
- Prevent “/login” to redirect to “/wp-login”
- Redirect User to login page
- All URLs Redirect to Main Page
- How to redirect user after login to the page called by his first name?
- redirect doesn’t work while using example code
- Why I am not able to direct user to my blog section without login?
- Redirect After Login Error
- Redirect certain pages if user logged in
- Force User Login
- wp_login_form redirect
- custom login form redirect problem
- Login redirect to previous page
- Trying to re-direct users to specific page based on an ACF variable
- Disable redirect to homepage after successful Login, Stay on Current Page
- Redirect to custom login page if not logged in and redirect to home if logged in user try to login, how?
- wp_login_form() redirect same page
- How force WordPress redirect to current custom page after login
- Hide a Post everywhere except on redirect
- Conditional Login Redirect
- Keep the old referrer after failed login
- Determine user destination on wp-login.php
- Redirect user after login to prior page through a wp_login hook
- How can force redirected to login for two or more pages to view or access
- How to redirect user to Referrer Page using wp_signon in Custom Login Page in WordPress
- Redirect after login when WordPress in subdirectory
- HOW do you Redirect buddypress login to EDIT tab not PROFILE tab on profile page? [closed]
- Login redirects to home page and doesn’t log in
- WordPress not loggin user and redirecting after custom registration
- redirect_to ignoring the SSL
- Redirect user on login using extra field value on login form
- Woocommerce login to specific page or referrer
- wp-login.php redirect problem
- login redirect problem – db charset issue?
- How to modify the WordPress comes with redirect
- Conditional redirect on login using referring URL
- Redirect problem: How to redirect to the original URL after login
- Custom Login Plugin Redirects to wp-login.php After Site Migration
- Login Form Redirection
- Redirect user to login and then to page where they came from
- WordPress Login Page redirecting after failed login
- Logging back into WordPress after logging out and having issues with ‘loggedout=true’ in redirect URL
- login page not working [closed]
- Redirect after user changes password
- redirect users to the login page
- WordPress redirect to splash page once a day for the first week
- Accept (once only) policy page on login
- login_redirect for Mobile Web
- wp_login_form: Redirect to dynamic url according to username
- How to disable login and registration pages?
- Redirecting logged in users to custom URL
- Upload Directory question