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

Redirecting logged in users to custom URL

You wouldn’t replace the $pagenow, but would check it’s value: 'wp-login.php' === $pagenow.

I recommend using one of the $_SERVER values, or WordPress helper functions (ex: is_page(), is_login()) on the template_redirect action hook.

add_action( 'template_redirect', static function () {
    if ( ! is_user_logged_in() ) {
        return;
    }

    if ( ! is_login() ) {
        return;
    }

    wp_redirect( 'https://customurl' );
    exit;
} );

Related Posts:

  1. Redirect user to original url after login?
  2. Login redirect to previous page
  3. Redirect to referring page after logging in
  4. check first time login only
  5. How to change the default logout link on WordPress Admin
  6. How to redirect after login, the working way?
  7. Password change when the user login first time
  8. Custom login form redirect to external site
  9. handling login/logout redirects
  10. Restrict Access to wp-login.php
  11. Using `auth_redirect` : keeps asking me to login even when I’m logged in
  12. Redirect users after first login
  13. Redirect to current page after wordpress login
  14. wp-login.php — redirect logged in users to custom URL
  15. Redirect user after login/registration globally
  16. Redirect to login page
  17. You do not have sufficient permissions to access this page
  18. Redirect user after logout
  19. how to do logout redirect to current url
  20. How to redirect user to specific page based on the input password
  21. How do I redirect a user when he is logged in after clicking on a menu
  22. How to modify the Register link in the login page?
  23. Changing “Lost Password Email Link” to custom password reset page
  24. How to redirect user to a specific page based on username?
  25. Redirect after password update
  26. How to redirect user after login to a specific page?
  27. Redirect Logged In User if page is wp-login.php and $_Get[‘level’] = X
  28. Redirect when accessing /login when logged in
  29. How to redirect after login getting a variable from url (for example with the language)
  30. If User is NOT Logged in and Page ID is not 6 – Redirect to Login
  31. Redirect to Current Page after Login
  32. How to include error message on login
  33. Login redirect problem
  34. How to redirect on login to a specific page if a specific meta user is empty
  35. redirect Login problems
  36. Redirect user to previous page after signup from custom form
  37. How can I force the user to log in, even if they’re already authenticated?
  38. User is logged in after Stripe payment, then redirected, but is then logged out again
  39. Login Redirect – Multiple Scenarios
  40. WooCommerce – Redirect to a product after login
  41. Usage of the login_redirect filter
  42. Login/Register redirect user with message
  43. Redirect user to original url after login?
  44. Prevent users from going to wordpress profile after login
  45. Custom form redirect after login
  46. Custom redirect user after login based on metadata
  47. Custom Login Form – Redirect user to login page if not logged in
  48. Redirection on Custom page
  49. Redirect user to specific link after login
  50. Load function with login_redirect
  51. Prevent “/login” to redirect to “/wp-login”
  52. Redirect User to login page
  53. All URLs Redirect to Main Page
  54. How to redirect user after login to the page called by his first name?
  55. redirect doesn’t work while using example code
  56. Why I am not able to direct user to my blog section without login?
  57. Redirect After Login Error
  58. Redirect certain pages if user logged in
  59. Force User Login
  60. wp_login_form redirect
  61. custom login form redirect problem
  62. Login redirect to previous page
  63. Trying to re-direct users to specific page based on an ACF variable
  64. Disable redirect to homepage after successful Login, Stay on Current Page
  65. Redirect to custom login page if not logged in and redirect to home if logged in user try to login, how?
  66. wp_login_form() redirect same page
  67. How force WordPress redirect to current custom page after login
  68. Hide a Post everywhere except on redirect
  69. Conditional Login Redirect
  70. Keep the old referrer after failed login
  71. Determine user destination on wp-login.php
  72. Redirect user after login to prior page through a wp_login hook
  73. How can force redirected to login for two or more pages to view or access
  74. How to redirect user to Referrer Page using wp_signon in Custom Login Page in WordPress
  75. Redirect after login when WordPress in subdirectory
  76. HOW do you Redirect buddypress login to EDIT tab not PROFILE tab on profile page? [closed]
  77. Login redirects to home page and doesn’t log in
  78. WordPress not loggin user and redirecting after custom registration
  79. redirect_to ignoring the SSL
  80. Redirect user on login using extra field value on login form
  81. Woocommerce login to specific page or referrer
  82. wp-login.php redirect problem
  83. login redirect problem – db charset issue?
  84. How to modify the WordPress comes with redirect
  85. Conditional redirect on login using referring URL
  86. Redirect problem: How to redirect to the original URL after login
  87. Custom Login Plugin Redirects to wp-login.php After Site Migration
  88. Login Form Redirection
  89. Redirect user to login and then to page where they came from
  90. WordPress Login Page redirecting after failed login
  91. Logging back into WordPress after logging out and having issues with ‘loggedout=true’ in redirect URL
  92. login page not working [closed]
  93. Redirect after user changes password
  94. redirect users to the login page
  95. WordPress redirect to splash page once a day for the first week
  96. Accept (once only) policy page on login
  97. login_redirect for Mobile Web
  98. wp_login_form: Redirect to dynamic url according to username
  99. How to disable login and registration pages?
  100. can’t handle a redirect
Categories redirect Tags login, redirect
Custom plugin doesn’t show in admin menu – when code added, displays an empty page
How to get posts by a certain author in inner loop using outer loop variable or post title WordPress

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

  • Disable image compression for WebP
  • At what stage does wp_ajax hooks gets applied during WordPress request?
  • How to create specific wordpress Table
  • How to get variable from other function inside class function using add_action for Ajax call
  • Some images not loading after changing IP on local wordpress install
  • search posts by POST ID
  • Elementor Contact Form Submit button has empty class
  • Duplicate Slugs on multilingual site (with Polylang)
  • Timeline from diferent wordpress api urls endpoint works, but diferent date
  • $attributes not defined in block.json PHP template for ACF blocks
© 2023 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