Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How can I login as admin after redirect to custom login page

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:

  1. custom login page redirect to logged in user profile page
  2. Action wp_login_failed not working if only one field is filled out
  3. Send reset password link to user from custom lost password form
  4. Restricting frontend acess based on user role otherwise redirect to login form
  5. wp_get_referer not working properly after wp_redirect
  6. WordPress/Buddypress login theme function [closed]
  7. Login redirects and query strings
  8. Redirect wp-login
  9. Replacing default display name to login name
  10. Do more action after login successfully
  11. Hide Author page from others
  12. Require re-login when logged-in user attempts to access restricted page
  13. This webpage has a redirect loop issue
  14. WordPress site login Redirect
  15. Problem in auto login after registration
  16. WordPress Redirect After logging
  17. redirect_to not Including Hashtag from URL
  18. A way to redirect users when they log in based on their current page
  19. Is there a way to give users the option to log in to their favorite group on login? [closed]
  20. Redirect non-members to about/intro page
  21. Login form- no feedback
  22. In Django, how do I know the currently logged-in user?
  23. Can I programmatically login a user without a password?
  24. Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
  25. Is there any way to rename or hide wp-login.php?
  26. How to login with email only no username?
  27. How can I redirect user after entering wrong password?
  28. Increase of failed login attempts, brute force attacks? [closed]
  29. Login page ERROR: Cookies are blocked due to unexpected output
  30. Separate registration and login for different roles
  31. SSO / authentication integration with external ‘directory service’
  32. Preventing session timeout
  33. How reduce wordpress login session timeout time?
  34. How to prefill WordPress registration with social details
  35. Check for correct username on custom login form
  36. Disallow user from editing their own profile information
  37. I can’t access my site via wp-admin
  38. ‘Password field is empty’ error when using autofill in Chrome
  39. Removing username from the ‘wordpress_logged_in’ cookie
  40. How to show ‘login error’ and ‘lost password’ on my template page?
  41. What is $interim_login?
  42. Custom login form
  43. How to prefill the username/password fields on the login page
  44. wp_signon returns user, but the user is not logged in
  45. Adding extra authentication field in login page
  46. Prevent wp_login_form() from redirecting to wp-admin when there are errors
  47. Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
  48. wp_signon() does not authenticate user guidance needed
  49. What exactly is ReAuth?
  50. What are the differences between wp_users and wp_usermeta tables?
  51. Login members using web services
  52. Make my wordpress blog remember my login “forever”
  53. How to check in timber if user is loggedin?
  54. How do I change the language of only the login page?
  55. Disable WordPress 3.6 idle logout / login modal window / session expiration
  56. Stop WordPress from logging me out (need to keep me logged in)
  57. Woocommerce registration page [closed]
  58. How to disable autocomplete on the wp-login.php page
  59. Share login data/cookies between multiple installations
  60. Synchronize WordPress user accounts across multiple domains and installations without using WordPress MU
  61. How to pass users back and forth using session data?
  62. How do I change the logo on the login page?
  63. Why does WordPress hide the reset password key from the URL?
  64. Is it possible to sign in with user_email in WordPress?
  65. How to use current_user_can()?
  66. Avoid to load default WP styles in login screen
  67. WordPress registration message
  68. How to fake a WordPress login?
  69. how to display the wordpress login and register forms on a page?
  70. Does wp_logout_url() destroy a session? (Logging out question)
  71. How can I send a welcome email to a user AFTER they login for the first time?
  72. Can not login with correct username and password
  73. Website Visible only to Registered users
  74. How can i increase the login expiration length?
  75. How to redirect after login, the working way?
  76. How do I use add_action from a class method?
  77. How to remove the WordPress logo from login and register page?
  78. How can I add a custom script to footer of login page?
  79. Brute force attack?
  80. Customize wp_new_user_notification_email()
  81. Need to execute a cron job
  82. Password change when the user login first time
  83. Login email after registration never sent or received
  84. How can I create a separate blog that is private?
  85. How to keep always logged in development environment
  86. Add Confirm Password field in wp-login.php Password Reset page
  87. Integrate recaptcha and wp_signon – what is needed?
  88. Stop users from logging in from multiple locations
  89. I want to disable E-Mail verifcation / activation when a user signs up for my WordPress site
  90. Email address or username used to login in wordpress
  91. How do I check if a post is private?
  92. Front-end login: Redirect user to the post they had created
  93. Receiving “This content cannot be displayed in a frame” error on login page
  94. My login form does not work
  95. Programmatically log in a wordpress user
  96. Getting “Cookies are blocked or not supported by your browser” on login page
  97. What is the purpose of logging out after WordPress upgrade?
  98. Is it alright for two people to simultaneously be logged into a WP site as administrator?
  99. wp-login.php redirecting to HTTPS
  100. Display last login time
Categories login Tags buddypress, login, wp-redirect
How can I make my metabox appear?
Enque script based on url paramater

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress