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
- SSO / authentication integration with external ‘directory service’
- Preventing session timeout
- Check for correct username on custom login form
- ‘Password field is empty’ error when using autofill in Chrome
- Prevent wp_login_form() from redirecting to wp-admin when there are errors
- How to disable autocomplete on the wp-login.php page
- how to display the wordpress login and register forms on a page?
- Is it alright for two people to simultaneously be logged into a WP site as administrator?
- How do I turn off the ability to login?
- WordPress Login Footer URL
- Save last login date in global before change it?
- How to get login data (session) outside WordPress?
- password protect individual pages
- Change register form action url
- Is back-end access not required for an app to post to my blog?
- Store brute-force IP addresses
- How do I make my site publicly viewable? Everything redirects to wp-admin
- How to create a private login page for admin.?
- WordPress Security – How to block alternative WordPress access
- Protecting WordPress login page
- Different homepage for logged in users
- reset password link redirect to login page
- Correct method of redirecting user login
- How can I force the user to log in, even if they’re already authenticated?
- SSO to WP, from a non-wp site on a different domain and server
- Login with serialized password
- is_user_logged_in() not working in Firefox
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Lock out all WordPress Administrators except two specific users
- Removing wordpress cookie from non-wordpress site
- Why does is_user_logged_in() return false after I change user password on the front end?
- ?login=failed only attached to URL under certain circumstances
- WordPress not logged in locally with correct username and password
- Requiring login for specific pages
- How to force “remember me” users to login again?
- Reset Password Limit not working
- User not able to sign in after wp_authenticate() and wp_signon() wordpress
- WordPress site login Redirect
- Thank You Page Layout Differs on User Logged In Status
- On Homepage “is_user_logged_in()” function is not working after login and it is working after refresh the page?
- Problem in auto login after registration
- Cant reset password my wordpress password not even with phpMyAdmin
- Get WordPress logged in username from root domain when WP is installed in a subfolder
- How to invalidate `password reset key` after being used
- wp-cron event doesn’t run when custom login API is enabled
- Does it make sense to check a nonce on user log in?
- Special link for no automatic login (no username and no password)
- Building a custom login form – encountering issues
- Making sure two different wordpress website has auto login
- Site login failed due to strange warning
- Improvements to “limit login attempts” plugin
- loging to Admin page not working at all
- Can’t login through wp-login.php on fresh installation
- WordPress Cookies – wp_set_auth_cookie
- Authenticate return value
- Front-end login problem: requires re-authorization when accessing dashboard
- Using wp_login_form passowrd as undefined
- Redirect non-members to about/intro page
- When trying to login if already logged in, form just shakes – error message remains empty
- Unable to login after adding ReCaptacha without API key
- How to create an alternative login page that does not use any plugins?