Try using the filter hook:
function user1462_login_redirect( $redirect_to, $request, $user ) {
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( 'administrator', $user->roles ) ) {
return $redirect_to . '?message=hiadmin';
} else {
return home_url();
}
} else {
return $redirect_to;
}
}
add_filter( 'login_redirect', 'user1462_login_redirect', 10, 3 );
Related Posts:
- Can I programmatically login a user without a password?
- What is $interim_login?
- Adding extra authentication field in login page
- What exactly is ReAuth?
- Login members using web services
- Disable WordPress 3.6 idle logout / login modal window / session expiration
- How to pass users back and forth using session data?
- How do I use add_action from a class method?
- Need to execute a cron job
- Action wp_login_failed not working if only one field is filled out
- wp_login action hook not working
- how to update current logged user username
- Validate Custom Login field
- Calling wp_signon doesn’t log the user in
- How to implement Google reCaptcha without installing a plugin?
- Is it possible a one click user registration with Facebook or Twitter (or other Social Networks)?
- Are there ways of logging in that bypass wp-login.php altogether?
- How to display username and password after registration
- How to modify the action attribute of the wp-login.php?action=register form?
- Two factor authentication
- How to generate “WP_Error” Object for user login?
- add_action(‘init’) not work
- Allow Access to Home Page and Login Screen but Nothing Else (unless logged in)
- Where is the php file, that does the checks for login information?
- I want login using email not username wordpress front end
- Custom login modal page action
- WordPress authentication using custom php?
- authenticate user without redirecting
- Multiple issues with Ajax login function due to browsers and cookies
- How to post frontend login form to a different authentication script from wp-login?
- Custom user roles are unable to login
- Using WordPress login for a non word-press website
- Extend Cookie with auth_cookie_expiration not working
- Can we start session from another php site to wordpress blog site?
- Opening protected page with cookie?
- Is there any reason why there’s no “login_header” action at the login page?
- Handle POST request sent from an external site for login?
- External Authentication
- Login and register by API
- index.php file shown when trying to load wesite
- Custom login form
- 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)
- Does wp_logout_url() destroy a session? (Logging out question)
- How to keep always logged in development environment
- Add Confirm Password field in wp-login.php Password Reset page
- Using `auth_redirect` : keeps asking me to login even when I’m logged in
- Gaining Login Access via the Database
- send users logging in from wp-login.php directly to home page of site, rather than dashboard
- Changing Login Logo
- Get user ID after logging in
- How can I retrieve the username and password from my WordPress installation?
- User Directory without a Plugin
- wp-admin seems to be redirecting
- Custom Connect to Facebook, problem logging in/logging out
- WordPress login urls
- Use WordPress with a custom OAuth2 provider
- WordPress Login page trashed
- Change Favicon on Login Screen?
- What’s hook to use immediately after a user is authentcated [duplicate]
- wp-login gives 404 error, but wp-admin is working fine
- Custom login message for single post pages only
- Password protect media attachment – share across guests
- Password reset – Disabled for LDAP accounts
- Replace dash with space in username on login
- Autologin only working the second time
- Completely replacing the login form
- 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
- I cannot login and am getting this error message. .
- Can I Get User ID at Login?
- WordPress SSL not working [closed]
- what is the best and safest way to allow users to register to site
- Sharing a logged in session with a custom subdmain site?
- 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
- check the first login for specific roles
- Make WordPress User Name be the Company Name when Registering (not the default ‘first name’ last name’ email address’)
- Why do I have a reauth=1 redirection loop when I try to log in to WordPress hosted on AWS Fargate?
- Confused – can’t access wordpress dashboard or site that has been published
- wordpress login loop and session problem
- unable to Login to Admin
- ERROR: Cookies are blocked due to unexpected output – ultimate solution
- Fatal error: Call to undefined function get_plugin_data()
- Make WordPress User Name the Email Address When Register
- Users redirected to old site
- WordPress Login / SSL = Code Question
- Save user login date
- Login with Username (or Code) only
- wp_signon gives error insufficient_permissions
- Is there a way to give users the option to log in to their favorite group on login? [closed]
- Securely log in a user without a password using a link?
- Logging in takes a few refreshes to show you are logged in, is this a cache issue? [closed]
- How to add a new link to the default register form’s footer links?
- Direct access to site when log in
- Can not login after moving to cloudflare and adding rules
- Inconsistent login state