Probably because the global $current_user
isn’t valid yet, which is used by current_user_can()
.
However, you can use this instead;
if ($user->has_cap('manage_options')) { return admin_url(); }
Related Posts:
- Custom login form
- Adding extra authentication field in login page
- Make my wordpress blog remember my login “forever”
- How to check in timber if user is loggedin?
- Stop WordPress from logging me out (need to keep me logged in)
- How can i increase the login expiration length?
- Brute force attack?
- custom login page redirect to logged in user profile page
- Front-end login: Redirect user to the post they had created
- What is the purpose of logging out after WordPress upgrade?
- How can I test the login for an expired session?
- How to translate “wrong password” message
- User Login Form Outside the Default wp-login Form
- Calling wp_signon doesn’t log the user in
- Login cookie across multiple domains on network w/ mapping
- Can’t login after URL change
- Register/Login using only phone number?
- Adding HTML to login page under the body tag
- force user to re-login after 4 hours – how?
- How does WordPress handle sessions?
- How to determine if a user has not changed default generated password
- Preexisting login to change to logout link in sub menu
- Customizing login error messages
- How can we redirect user from login page to home page if user is logged in WordPress?
- When can I safely `wp_set_auth_cookie`?
- screwed-up my blog..what should I do
- Changes only show when logged in?
- How can I find the login page? It was lost after moving the site
- How to redirect to specific BLOG Dashboard (after login to Multi-Site)
- How to integrate external user tables with WP?
- WordPress as webapp login session
- replace wp-login.php login forms via a hook & use custom forms with wp-login form validation
- How to modify the action attribute of the wp-login.php?action=register form?
- How can I add a login/logout link in the sub-nav of my website?
- Correct passwords keep appearing as incorrect
- Odd login issue that needs manual page refresh on some devices
- WordPress asking for login on public pages on localhost
- Session Experies and Get Logged Out Within Few Minutes
- Show directory listing/browsing if user is logged in
- Two factor authentication
- Disabling standard registration login with username/email and password?
- Login form doesn’t log in
- Possible to display a button only if user are login?
- Disable all other page except index,register,login till user login
- Is wp_login_form secure on a non secure page?
- Which modification to login only certain role?
- Auto login after reset password
- Require login for specific templates
- Is there anyway to get the inputted password string from the login form?
- Invalidate username if it contains @ symbol
- WordPress Login and Register Link
- Login and Forgot password in Lightbox
- WordPress Login redirection according to user role
- Getting a person’s username from a wordpress cookie
- Prevent display password on wp-login.php
- WordPress ‘limit_login_lockouts’ using internal ip adress
- wp_get_current_user does not work properly on log in page
- How do I limit access to wp-admin to an IP range?
- Where is the php file, that does the checks for login information?
- WordPress Logout Problem [closed]
- “if is logged in” doesn’t work for me [closed]
- Timezone Change Locked Me Out? [closed]
- One time login on 2 different WordPress sites
- Remove a message in login page
- How are all users now set to inactive?
- Membership Plugin with Facebook integration [closed]
- How to create separate login for authors/moderators/subscribers?
- Login Based on ip
- Unable to login into WordPress 401
- Custom user roles are unable to login
- Google reCaptcha on WP login page
- Recovering log in information
- Log in only by email and no username
- Extend Cookie with auth_cookie_expiration not working
- Modify wp-login.php Labels Conditionally Based On Referring URL
- WordPress login page not display
- WordPress Login & Register works in localhost but don’t work on server
- Opening WordPress on wordpress.example.com, while the webpage is at example.com
- Stop customers and subscribers from login to dashboard
- prevent login after incorrect password 5 times
- Why does /wp-admin login send me to this landing page?
- Locked out of WordPress admin area [closed]
- WordPress login page blank after customizations – works on other sites
- WordPress does not send email confirmation to newly registered users
- How to dequeue the default CSS styles on the wp-login.php page?
- confirmation email is send from my local host registration of a user but mail will not display in there email account?
- Server error after log in
- How do I resolve my inability to login to WordPress dashboard? [duplicate]
- Chrome incorrectly displaying WP login as ‘not fully secure’
- Changed from HTTP to HTTP, can login no longer login
- Hide wp-login.php but not the widget
- Without user loging inner page is disable wordpress [duplicate]
- Registration and Login form
- WordPress and Magento: let WordPress manage user registration and logins?
- Share login status across subdomains without network
- How to change the login URL
- redirect not logged in users to specific page and redirect them back where they come from
- Click on banner to register to the blog
- Login and register by API
- Log in a user upon password reset?