I believe init
is too early to determine is_page()
. Try a later hook, like template_redirect
.
function wpse_344136_user_logged_in(){
if ( is_user_logged_in() && is_page( 'login' ) ){
wp_redirect( home_url() );
exit;
}
}
add_action( 'template_redirect', 'wpse_344136_user_logged_in' );
Related Posts:
- How do I use add_action from a class method?
- Action wp_login_failed not working if only one field is filled out
- wp_login action hook not working
- How to modify the action attribute of the wp-login.php?action=register form?
- Reloading page with a query string upon login for admins
- Custom login modal page action
- wp-cron event doesn’t run when custom login API is enabled
- Is there any reason why there’s no “login_header” action at the login page?
- In Django, how do I know the currently logged-in user?
- Disallow user from editing their own profile information
- wp_signon returns user, but the user is not logged in
- What exactly is ReAuth?
- What are the differences between wp_users and wp_usermeta tables?
- How can I send a welcome email to a user AFTER they login for the first time?
- Can not login with correct username and password
- How to remove the WordPress logo from login and register page?
- Stop users from logging in from multiple locations
- My login form does not work
- Cookie settings for session across WPML subdomains using custom AJAX login
- Change Login Page for a Multisite Subsite
- Change admin login URL
- Is there a way to remove wp-login.php alias (login)?
- wp-admin redirecting to wp-login.php
- Get wordpress stored cookies for custom login
- wp_redirect() not working on form submission with init hook
- Restrict PDF links
- Can’t access login page after password reset
- Remote REST request to check login status
- How can I test the login for an expired session?
- Rendering of custom walker menu function not working properly
- Force user to login in home page
- add filter login_redirect does not contain original requested redirect
- Login as a client no dashboard menu?
- Allow access to a page for admins only
- How to edit comment_reply_link
- Right practice to edit WP reset password email
- deny IPs from wp-login using .htaccess
- How can I prevent my custom form from redirecting to wp-login?
- Custom Login iframe doesn’t work
- wp-admin returns 404 [closed]
- What would be the best way to implement Magic Link logins in WordPress?
- Can’t login to WordPress without hitting the Remember Me checkbox. Potential SSL implementation bi-product
- disable site_url redirect in wp-login.php
- Forgot password needs to redirect from wp-login to a custom page
- Is it possible to designate the login.php as homepage?
- Force login for a subdirectory within wordpress install
- Redirect login page except on reset pass
- Redirect users after failed login attempt?
- How to secure files based on format and word in file name with wp-config or htaccess?
- Get the url of custom login page in the registration page
- How to make wp-login.php not accessible
- Single sign on with custom site
- By registering always make uppercase the first letter of the login
- Best option to implement external register/login to WP from self-made API
- Enqueue new login style sheet
- WordPress Conditional Login Links
- Secure login on wordpress [closed]
- Do more action after login successfully
- How can I password protect a WordPress site without requiring users to log in?
- Can’t login to my own website
- Change default login auth
- I can’t access my WordPress dashboard – shows Warning message [closed]
- Add html to wp_login_form
- Access log “POST /wp-login.php HTTP/1.0” 400
- Are login functions considered part of the WP backend?
- SQL – Remove All The Users and Create A New User With Admin Role Via PhpMyAdmin
- Can I protect a type of content site-wide with a single password?
- Sign in with social media accounts without creating a WP account [closed]
- WordPress login form script
- WordPress authentication using custom php?
- what is the best and safest way to allow users to register to site
- ERROR: Cookies are blocked due to unexpected output (no FTP access)
- Sharing a logged in session with a custom subdmain site?
- How do I change the language of the login page to Arabic?
- How to redirect a unique link based on login status
- MAMP localhost wordpress site, not possible to sign in, username and password are correct
- Login issues wordpress page
- How to post frontend login form to a different authentication script from wp-login?
- Why do I have a reauth=1 redirection loop when I try to log in to WordPress hosted on AWS Fargate?
- Login form does not store/remember/suggest users password
- Problem with is_user_logged_in() function in some pages
- Confused – can’t access wordpress dashboard or site that has been published
- wordpress login loop and session problem
- unable to Login to Admin
- WordPress login loop on proxy setup with SSL – Apache proxy to IIS
- ERROR: Cookies are blocked due to unexpected output – ultimate solution
- Android app – can’t login: “This site already exists in the app, you can’t add it”
- Fatal error: Call to undefined function get_plugin_data()
- backend access per user status
- Make WordPress User Name the Email Address When Register
- Users redirected to old site
- WordPress Login / SSL = Code Question
- Enqueue script on logon failure
- I get 404 when I try to login ever since I changed the permalink
- wp_signon gives error insufficient_permissions
- Logging in takes a few refreshes to show you are logged in, is this a cache issue? [closed]
- Inconsistent login state
- Can i hide a dynamically created div to logged out users?
- Why am I not able to login to the admin
- WP behind haproxy weirdness