The code logic above may not evaluate to true, refactor it like so:
function custom_level_login_redirect() { $isPageLogin = is_page('login'); $isUserLoggedIn = is_user_logged_in(); $level = (int) $_GET['level']; if( $isPageLogin && isUserLoggedin && $level > 0 ) { $redirect_to = esc_url_raw( site_url("membership-account/membership-checkout/?level=" . $level, null) ); exit( wp_redirect( $redirect_to ) ); } return; } add_action('login_init', 'custom_level_login_redirect');
Notice the esc_url_raw(), the $level variable casting, and the if() statement.
Related Posts:
- Password change when the user login first time
- wp-login.php — redirect logged in users to custom URL
- Redirect user after login/registration globally
- Redirect to login page
- Redirect user to previous page after signup from custom form
- Redirect User to login page
- Trying to re-direct users to specific page based on an ACF variable
- Keep the old referrer after failed login
- wp_redirect() function is not working
- Redirect page URL to home URL without using a plugin
- Login redirect to previous page
- check first time login only
- How to change the default logout link on WordPress Admin
- WordPress HTTPS redirect loop
- How to redirect after login, the working way?
- Custom login form redirect to external site
- handling login/logout redirects
- Restrict Access to wp-login.php
- Using `auth_redirect` : keeps asking me to login even when I’m logged in
- Redirect users after first login
- Stop unwanted WP redirection to new url
- Redirect to current page after wordpress login
- Temporary redirect prevents getting $_POST array
- URL Redirect and Bulk Actions in wp_list_table
- Redirect user after logout
- How to redirect user to specific page based on the input password
- Firing a function AFTER redirect
- How to auto login after registration? [duplicate]
- How do I redirect /search/ to ?s=
- How to redirect user to a specific page based on username?
- How to redirect to home page after registration?
- How to redirect user after login to a specific page?
- How to use Regex to add to a url?
- Stuck In a Redirect Loop
- Redirect when accessing /login when logged in
- If User is NOT Logged in and Page ID is not 6 – Redirect to Login
- Redirect to Current Page after Login
- Login redirect problem
- Adding rewrite rule dynamically for search results redirecting to 404 URL
- How to redirect if a background request is still being executed
- User is logged in after Stripe payment, then redirected, but is then logged out again
- Get query parameters from external url and make a redirection
- Login Redirect – Multiple Scenarios
- wordpress_redirect returns different headers for HEAD and GET requests
- Usage of the login_redirect filter
- Show different page for first time user
- Login/Register redirect user with message
- Redirect user to original url after login?
- Redirect outside WP after login
- store URL global before we redirect
- Custom Login Form – Redirect user to login page if not logged in
- How to redirect from one WP site to another
- How do I write a subdomain redirect?
- How to fix automatic redirects?
- How to redirect user after login to the page called by his first name?
- redirect doesn’t work while using example code
- Redirect After Login Error
- Redirecting simple big problem
- Login redirect to previous page
- How to redirect a child page to its parent 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?
- Redirect to custom login page if not logged in and redirect to home if logged in user try to login, how?
- 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
- Hide a Post everywhere except on redirect
- Conditional Login Redirect
- How to redirect if 404 error in wordpress then redirect 404.php url
- ERR_TOO_MANY_REDIRECTS when switching from good database to old database
- Redirect to /404/
- How to automatically redirect category pages (301) when changing the location of a category in the hierarchy
- Redirect user after login to prior page through a wp_login hook
- How can force redirected to login for two or more pages to view or access
- How to redirect user to Referrer Page using wp_signon in Custom Login Page in WordPress
- HOW do you Redirect buddypress login to EDIT tab not PROFILE tab on profile page? [closed]
- Login redirects to home page and doesn’t log in
- redirect after account activation for forum using bbpress and buddypress
- using wp_rewrite but keep the original url in the address bar
- redirect_to ignoring the SSL
- Redirect user on login using extra field value on login form
- Woocommerce login to specific page or referrer
- wp-login.php redirect problem
- login redirect problem – db charset issue?
- How to redirect 404s that generated for css&JS files?
- Redirect problem: How to redirect to the original URL after login
- Login Form Redirection
- login page not working [closed]
- Redirect after user changes password
- WordPress redirect to splash page once a day for the first week
- Accept (once only) policy page on login
- wp_login_form: Redirect to dynamic url according to username
- problem redirecting users to page on login
- Create a 301 Redirect automatically when adding %category% in the permalink
- Other pages fine but wp-admin showing ERR_TOO_MANY_REDIRECTS Error
- How to disable login and registration pages?
- Post Migration Site Migration Redirects All Known Solutions Attempted
- wp_redirect() doesn’t work
- Redirecting logged in users to custom URL