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 to redirect user after login to a specific page?

In your login link you call the WordPress function wp_login_url() to generate the login URL. Mr Peattie’s question in the comments refers to the documented parameter redirect supported by this function. When in doubt, always check the documentation: https://developer.wordpress.org/reference/functions/wp_login_url/

There are actually two parameters for wp_login_url() but for the purpose of your question, the first one is all you need to provide.

Making use of the redirect parameter will tell WordPress where to send a user that completes login successfully. Assuming your link to the login form is coming from a template for the About Us page that you wish to return to, the current page permalink can be used as the value for the parameter like this:

wp_login_url( get_permalink() )

Look at the output of that command and you will see the query parameter on the login URL that is output by WordPress.

If you are using the login URL function somewhere else and need the About Us page as the redirect target, simply enter it as a string, like this:

wp_login_url( '/about-us' ) )

For a better user experience, check the current user’s login status before showing the login link. Putting that together with the rest of your code:

<?php if ( ! is_user_logged_in() ) : ?>
    <p>You need to be logged in in order to view this content. Would you like to <a href="<?php echo esc_url( wp_login_url( '/about-us' ) ); ?>"><?php _e('log in') ?></a> now?</p>
<?php endif; ?>

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. after login that will redirect user role into a page
  13. Redirect users after first login
  14. Redirect to current page after wordpress login
  15. wp-login.php — redirect logged in users to custom URL
  16. Redirect user after login/registration globally
  17. Redirect to login page
  18. You do not have sufficient permissions to access this page
  19. Redirect user after logout
  20. how to do logout redirect to current url
  21. How to redirect user to specific page based on the input password
  22. How do I redirect a user when he is logged in after clicking on a menu
  23. How to modify the Register link in the login page?
  24. Changing “Lost Password Email Link” to custom password reset page
  25. How to redirect user to a specific page based on username?
  26. Redirect after password update
  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. How to redirect if a background request is still being executed
  36. redirect Login problems
  37. Redirect user to previous page after signup from custom form
  38. How can I force the user to log in, even if they’re already authenticated?
  39. User is logged in after Stripe payment, then redirected, but is then logged out again
  40. Login Redirect – Multiple Scenarios
  41. WooCommerce – Redirect to a product after login
  42. Usage of the login_redirect filter
  43. Login/Register redirect user with message
  44. Redirect user to original url after login?
  45. Prevent users from going to wordpress profile after login
  46. Redirect user if they are not logged in
  47. Custom form redirect after login
  48. Custom redirect user after login based on metadata
  49. Custom Login Form – Redirect user to login page if not logged in
  50. Redirection on Custom page
  51. Redirect user to specific link after login
  52. Load function with login_redirect
  53. Prevent “/login” to redirect to “/wp-login”
  54. Redirect User to login page
  55. All URLs Redirect to Main Page
  56. How to redirect user after login to the page called by his first name?
  57. redirect doesn’t work while using example code
  58. Why I am not able to direct user to my blog section without login?
  59. Redirect After Login Error
  60. Redirect certain pages if user logged in
  61. Force User Login
  62. wp_login_form redirect
  63. custom login form redirect problem
  64. Login redirect to previous page
  65. Trying to re-direct users to specific page based on an ACF variable
  66. Disable redirect to homepage after successful Login, Stay on Current Page
  67. Redirect to custom login page if not logged in and redirect to home if logged in user try to login, how?
  68. wp_login_form() redirect same page
  69. How force WordPress redirect to current custom page after login
  70. Hide a Post everywhere except on redirect
  71. Conditional Login Redirect
  72. How to redirect a unique link based on login status
  73. Keep the old referrer after failed login
  74. Determine user destination on wp-login.php
  75. Redirect user after login to prior page through a wp_login hook
  76. Make a treatment before the action of the form
  77. How can force redirected to login for two or more pages to view or access
  78. How to redirect user to Referrer Page using wp_signon in Custom Login Page in WordPress
  79. Redirect after login when WordPress in subdirectory
  80. HOW do you Redirect buddypress login to EDIT tab not PROFILE tab on profile page? [closed]
  81. Login redirects to home page and doesn’t log in
  82. WordPress not loggin user and redirecting after custom registration
  83. redirect_to ignoring the SSL
  84. Redirect user on login using extra field value on login form
  85. Woocommerce login to specific page or referrer
  86. wp-login.php redirect problem
  87. login redirect problem – db charset issue?
  88. How to modify the WordPress comes with redirect
  89. Conditional redirect on login using referring URL
  90. Redirect problem: How to redirect to the original URL after login
  91. Custom Login Plugin Redirects to wp-login.php After Site Migration
  92. Login Form Redirection
  93. Redirect user to login and then to page where they came from
  94. WordPress Login Page redirecting after failed login
  95. Logging back into WordPress after logging out and having issues with ‘loggedout=true’ in redirect URL
  96. login page not working [closed]
  97. Redirect after user changes password
  98. redirect users to the login page
  99. WordPress redirect to splash page once a day for the first week
  100. Accept (once only) policy page on login
Categories redirect Tags actions, login, redirect
Missing .twig files in wordpress theme editor
Changed permalink structure. Need help with redirecting old posts

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