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:
- Redirect user after login/registration globally
- How to auto login after registration? [duplicate]
- How to redirect to home page after registration?
- Redirect outside WP after login
- Redirect User to login page
- How to redirect new registrars to a custom registration page instead of WP default registration page?
- wp_redirect() function is not working
- Redirect page URL to home URL without using a plugin
- Why is wp_redirect() preferable to a standard PHP header redirect?
- How to redirect a sucessful registration to a page template?
- WordPress HTTPS redirect loop
- Password change when the user login first time
- Custom login form redirect to external site
- Clarification on auth_redirect()
- How to redirect all requests to wp-login.php?
- Redirect to custom url when registration fails?
- Restrict Access to wp-login.php
- Redirect to custom URL after registering from a page with registration form
- Stop unwanted WP redirection to new url
- wp-login.php — redirect logged in users to custom URL
- Redirect to “All Posts” after post update or publish in Block Editor
- Redirecting old site links to new site
- Redirect to login page
- Temporary redirect prevents getting $_POST array
- Creating intro page in wordpress
- URL Redirect and Bulk Actions in wp_list_table
- Remove lost password form and URL
- How to redirect only if page doesn’t exists
- Headers already sent – WordPress core
- How to redirect action=register link on the lostpassword page to a different link?
- Perform a redirect after user action
- How To Only Allow Users To View Their Own Buddypress Profiles? [closed]
- How do I redirect a user when he is logged in after clicking on a menu
- Custom Registration page – prevent redirect to wp-login.php?action=register
- Change ‘Back To Website’ link in wp-login.php
- Redirect away from login page
- How to modify the Register link in the login page?
- header and wp_redirect not working. cannot modify header information warning
- Code to create a redirection after login?
- How do I redirect /search/ to ?s=
- WordPress Global Redirect
- Why does wp_redirect strip out %0A (url encoded new line character) and how do I make it stop?
- Redirect if $_Server[‘REQUEST_URI’] is /wp-login.php?checkemail=registered
- Redirect the non-www version of the site to the www
- Redirect Logged In User if page is wp-login.php and $_Get[‘level’] = X
- How to use Regex to add to a url?
- Redirect first category archive page to normal page
- Stuck In a Redirect Loop
- Redirect when accessing /login when logged in
- How to set 301 redirection after moving WordPress blog?
- Can I change default registration link (without htaccess)?
- Front end user creation form! How do you keep the user on the same page in event of error?
- Adding rewrite rule dynamically for search results redirecting to 404 URL
- Force WordPress to load from site’s hostname
- How to redirect if a background request is still being executed
- Redirect custom post type from one domain to another domain
- How To Redirect /url.html to /url?
- I get redirected too many times only in wp-admin?
- Redirect user to previous page after signup from custom form
- Get query parameters from external url and make a redirection
- Redirect users after register (first login) and force submit post
- wordpress_redirect returns different headers for HEAD and GET requests
- Remove #wpcf7-f2450-o1 with Contact form 7 redirect [closed]
- How to pass a message using template_redirect
- Show different page for first time user
- Login/Register redirect user with message
- HTML Redirect to WP pages
- Why does the $_GET parameter ?search forward the front-page to the archive/blog page
- store URL global before we redirect
- wp_redirect () doesn’t work in nginx?
- wp_login_form redirect problem
- Is it possible to wp_redirect() to a new tab?
- Redirect Attachment Page to Attachment
- How to redirect from one WP site to another
- How do I write a subdomain redirect?
- How to fix automatic redirects?
- Create header.php redirect in WordPress and with WPML
- How to redirect wp_login_form to new page after user loged in?
- Missing domain http://./wp-… in redirects
- redirect doesn’t work while using example code
- Why I am not able to direct user to my blog section without login?
- Redirecting simple big problem
- Date based redirects of posts that no longer exist
- Redirect Page ID, based on logged-in User Role
- Trying to re-direct users to specific page based on an ACF variable
- How to redirect a child page to its parent page?
- Bulk redirect all post
- Disable redirect to homepage after successful Login, Stay on Current Page
- WordPress multi domain: page redirect to main domain whenever WordPress do the URL guessing issue
- Applying ‘middleware’ to a url before redirecting? Does WP have built in mechanism for this?
- How can I prevent caching of wp_redirect?
- Debugging issue with redirection in WordPress
- Add base folder to CPT and 301
- How do redirect user back to previous page when on certain pages?
- wp_login_form() redirect same page
- How do I redirect the browser to 404 page, if no posts are found in home page
- Keep the old referrer after failed login
- How to remove redirection
- Re-Direct ALL Users to the Home Page IF not logged in
- How to redirect if 404 error in wordpress then redirect 404.php url