There is no reason to redirect the logged-in users. So I would recommend that you add another conditional and redirect the users only if they are not logged in:
add_action('init','possibly_redirect');
function possibly_redirect(){
global $pagenow;
if( 'wp-login.php' == $pagenow && ! is_user_logged_in()) {
wp_redirect('http://localhost/test/login/');
exit();
}
}
This way you won’t be redirected after login.
Related Posts:
- custom login page redirect to logged in user profile page
- Action wp_login_failed not working if only one field is filled out
- Send reset password link to user from custom lost password form
- Restricting frontend acess based on user role otherwise redirect to login form
- wp_get_referer not working properly after wp_redirect
- WordPress/Buddypress login theme function [closed]
- Login redirects and query strings
- Redirect wp-login
- Replacing default display name to login name
- Do more action after login successfully
- Hide Author page from others
- Require re-login when logged-in user attempts to access restricted page
- This webpage has a redirect loop issue
- WordPress site login Redirect
- Problem in auto login after registration
- WordPress Redirect After logging
- redirect_to not Including Hashtag from URL
- A way to redirect users when they log in based on their current page
- Is there a way to give users the option to log in to their favorite group on login? [closed]
- Redirect non-members to about/intro page
- Login form- no feedback
- Adding extra authentication field in login page
- Make my wordpress blog remember my login “forever”
- How to check in timber if user is loggedin?
- Stop WordPress from logging me out (need to keep me logged in)
- Does wp_logout_url() destroy a session? (Logging out question)
- Customize wp_new_user_notification_email()
- Need to execute a cron job
- Login email after registration never sent or received
- How to keep always logged in development environment
- Add Confirm Password field in wp-login.php Password Reset page
- Gaining Login Access via the Database
- send users logging in from wp-login.php directly to home page of site, rather than dashboard
- Changing Login Logo
- Get user ID after logging in
- How can I retrieve the username and password from my WordPress installation?
- User logon by using mobile number [closed]
- Pre checking condition before login
- wp-admin seems to be redirecting
- WordPress login urls
- Redirect after empty login username and password
- WordPress Login page trashed
- Customizing the WordPress login form
- How to display username and password after registration
- wp-login gives 404 error, but wp-admin is working fine
- Login error redirecting to wp-login page
- Custom login message for single post pages only
- Private page protected with username and password
- Password protect media attachment – share across guests
- Password reset – Disabled for LDAP accounts
- Completely replacing the login form
- Show directory listing/browsing if user is logged in
- Two factor authentication
- Disabling standard registration login with username/email and password?
- Login form doesn’t log in
- Disable all other page except index,register,login till user login
- Which modification to login only certain role?
- Auto login after reset password
- Require login for specific templates
- How to redirect non-logged in users to login with post_password_required()
- Is there anyway to get the inputted password string from the login form?
- Invalidate username if it contains @ symbol
- WordPress Login and Register Link
- Login and Forgot password in Lightbox
- Prevent display password on wp-login.php
- WordPress ‘limit_login_lockouts’ using internal ip adress
- wp_get_current_user does not work properly on log in page
- How do I limit access to wp-admin to an IP range?
- Where is the php file, that does the checks for login information?
- WordPress Logout Problem [closed]
- “if is logged in” doesn’t work for me [closed]
- Timezone Change Locked Me Out? [closed]
- One time login on 2 different WordPress sites
- Membership Plugin with Facebook integration [closed]
- Unable to login into WordPress 401
- Custom user roles are unable to login
- Google reCaptcha on WP login page
- Log in only by email and no username
- Extend Cookie with auth_cookie_expiration not working
- Modify wp-login.php Labels Conditionally Based On Referring URL
- WordPress login page not display
- WordPress Login & Register works in localhost but don’t work on server
- Opening WordPress on wordpress.example.com, while the webpage is at example.com
- Stop customers and subscribers from login to dashboard
- prevent login after incorrect password 5 times
- WordPress login page blank after customizations – works on other sites
- WordPress does not send email confirmation to newly registered users
- How to dequeue the default CSS styles on the wp-login.php page?
- confirmation email is send from my local host registration of a user but mail will not display in there email account?
- Server error after log in
- How do I resolve my inability to login to WordPress dashboard? [duplicate]
- Chrome incorrectly displaying WP login as ‘not fully secure’
- Changed from HTTP to HTTP, can login no longer login
- Hide wp-login.php but not the widget
- Registration and Login form
- WordPress and Magento: let WordPress manage user registration and logins?
- Share login status across subdomains without network
- How to change the login URL
- Click on banner to register to the blog
- Must Log In to Visit Site [duplicate]