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

Redirect after registration and auto login is not working

I was able to get your code to work with the help of the answers to this question. I think you only need wp_set_current_user and wp_set_auth_cookie for the login functionality. Here is my revision of your innermost nested conditional, the rest is the same:

if (!is_wp_error($user_id)) {
              
  wp_set_current_user($user_id);
  wp_set_auth_cookie($user_id);
            
  $url = home_url() . '/redirect';
              
  wp_redirect( $url );
  exit;
}

Related Posts:

  1. Redirect user after login/registration globally
  2. How to auto login after registration? [duplicate]
  3. How to redirect to home page after registration?
  4. Redirect outside WP after login
  5. Redirect User to login page
  6. How to redirect new registrars to a custom registration page instead of WP default registration page?
  7. wp_redirect() function is not working
  8. Redirect page URL to home URL without using a plugin
  9. Why is wp_redirect() preferable to a standard PHP header redirect?
  10. How to redirect a sucessful registration to a page template?
  11. WordPress HTTPS redirect loop
  12. Password change when the user login first time
  13. Custom login form redirect to external site
  14. Clarification on auth_redirect()
  15. How to redirect all requests to wp-login.php?
  16. Redirect to custom url when registration fails?
  17. Restrict Access to wp-login.php
  18. Redirect to custom URL after registering from a page with registration form
  19. Stop unwanted WP redirection to new url
  20. wp-login.php — redirect logged in users to custom URL
  21. Redirect to “All Posts” after post update or publish in Block Editor
  22. Redirecting old site links to new site
  23. Redirect to login page
  24. Temporary redirect prevents getting $_POST array
  25. Creating intro page in wordpress
  26. URL Redirect and Bulk Actions in wp_list_table
  27. Remove lost password form and URL
  28. How to redirect only if page doesn’t exists
  29. Headers already sent – WordPress core
  30. How to redirect action=register link on the lostpassword page to a different link?
  31. Perform a redirect after user action
  32. How To Only Allow Users To View Their Own Buddypress Profiles? [closed]
  33. How do I redirect a user when he is logged in after clicking on a menu
  34. Custom Registration page – prevent redirect to wp-login.php?action=register
  35. Change ‘Back To Website’ link in wp-login.php
  36. Redirect away from login page
  37. How to modify the Register link in the login page?
  38. header and wp_redirect not working. cannot modify header information warning
  39. Code to create a redirection after login?
  40. How do I redirect /search/ to ?s=
  41. WordPress Global Redirect
  42. Why does wp_redirect strip out %0A (url encoded new line character) and how do I make it stop?
  43. Redirect if $_Server[‘REQUEST_URI’] is /wp-login.php?checkemail=registered
  44. Redirect the non-www version of the site to the www
  45. Redirect Logged In User if page is wp-login.php and $_Get[‘level’] = X
  46. How to use Regex to add to a url?
  47. Redirect first category archive page to normal page
  48. Stuck In a Redirect Loop
  49. Redirect when accessing /login when logged in
  50. How to set 301 redirection after moving WordPress blog?
  51. Can I change default registration link (without htaccess)?
  52. Front end user creation form! How do you keep the user on the same page in event of error?
  53. Adding rewrite rule dynamically for search results redirecting to 404 URL
  54. Force WordPress to load from site’s hostname
  55. How to redirect if a background request is still being executed
  56. Redirect custom post type from one domain to another domain
  57. How To Redirect /url.html to /url?
  58. I get redirected too many times only in wp-admin?
  59. Redirect user to previous page after signup from custom form
  60. Get query parameters from external url and make a redirection
  61. Redirect users after register (first login) and force submit post
  62. wordpress_redirect returns different headers for HEAD and GET requests
  63. Remove #wpcf7-f2450-o1 with Contact form 7 redirect [closed]
  64. How to pass a message using template_redirect
  65. Show different page for first time user
  66. Login/Register redirect user with message
  67. HTML Redirect to WP pages
  68. Why does the $_GET parameter ?search forward the front-page to the archive/blog page
  69. store URL global before we redirect
  70. wp_redirect () doesn’t work in nginx?
  71. wp_login_form redirect problem
  72. Is it possible to wp_redirect() to a new tab?
  73. Redirect Attachment Page to Attachment
  74. How to redirect from one WP site to another
  75. How do I write a subdomain redirect?
  76. How to fix automatic redirects?
  77. Create header.php redirect in WordPress and with WPML
  78. How to redirect wp_login_form to new page after user loged in?
  79. Missing domain http://./wp-… in redirects
  80. redirect doesn’t work while using example code
  81. Why I am not able to direct user to my blog section without login?
  82. Redirecting simple big problem
  83. Date based redirects of posts that no longer exist
  84. Redirect Page ID, based on logged-in User Role
  85. Trying to re-direct users to specific page based on an ACF variable
  86. How to redirect a child page to its parent page?
  87. Bulk redirect all post
  88. Disable redirect to homepage after successful Login, Stay on Current Page
  89. WordPress multi domain: page redirect to main domain whenever WordPress do the URL guessing issue
  90. Applying ‘middleware’ to a url before redirecting? Does WP have built in mechanism for this?
  91. How can I prevent caching of wp_redirect?
  92. Debugging issue with redirection in WordPress
  93. Add base folder to CPT and 301
  94. How do redirect user back to previous page when on certain pages?
  95. wp_login_form() redirect same page
  96. How do I redirect the browser to 404 page, if no posts are found in home page
  97. Keep the old referrer after failed login
  98. How to remove redirection
  99. Re-Direct ALL Users to the Home Page IF not logged in
  100. How to redirect if 404 error in wordpress then redirect 404.php url
Categories redirect Tags redirect, user-registration, wp-login-form, wp-redirect
Change formatting of Date parameter on custom post type
Add Additional Column in “Users” Dashboard Area – BP Extended Profiles (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

  • 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