You’re using the filter wrong. If you got more than one @param, then you have to state them when adding the filter.
function wpse40745_redirect_on_login( $redirect_to, isset( $_REQUEST['redirect_to'] ), $user )
{
# uncomment the following line if it's not working and replace $user->roles[0] with something that works
// echo '<pre>'; print_r( $user ); echo '</pre>'; exit;
if ( in_array( $user->roles[0], array( 'contributer', 'whatever_other_role ) ) )
return home_url();
return $redirect_to;
}
add_filter( 'login_redirect', 'wpse40745_redirect_on_login', 20, 3 );
Related Posts:
- Custom user roles are unable to login
- Separate registration and login for different roles
- Disallow user from editing their own profile information
- Website Visible only to Registered users
- moving server can not login
- how to update current logged user username
- How can I allow access to two user accounts using one login?
- Redirecting or displaying a message on first login
- Restricting frontend acess based on user role otherwise redirect to login form
- Deny a user role to log in after register
- Private page protected with username and password
- Password protect media attachment – share across guests
- How to integrate external user tables with WP?
- Allow Users Only Edit Their Profile?
- WordPress login problem
- Set Default User Role
- Lock out all WordPress Administrators except two specific users
- Generate email on meta value update
- Prevent Subscriber Role to login
- How to restrict access to a single for users I’ve authorized? [closed]
- 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]
- Login Based on ip
- URL Restrictions? Need only people who are logged in AND have a specific role (or roles) to access all pages for a site
- Custom failed login error messages for users based on user role?
- How to show private pages based on a user’s role?
- How to password protect pages in WordPress
- How to lock WordPress front-end with login and password?
- Creating Custom Login Form Where Password Field is Dropdown Menu
- Custom login form
- Adding extra authentication field in login page
- How to check in timber if user is loggedin?
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- Stop WordPress from logging me out (need to keep me logged in)
- Hide Admin Menu for Specific User ID who has administrator Role
- Customize wp_new_user_notification_email()
- Need to execute a cron job
- Temporarily disable user role login and replace with message
- How can I retrieve the username and password from my WordPress installation?
- User Directory without a Plugin
- Pre checking condition before login
- Custom Connect to Facebook, problem logging in/logging out
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- WordPress login urls
- Redirect after empty login username and password
- WordPress Login page trashed
- Are there ways of logging in that bypass wp-login.php altogether?
- Change Favicon on Login Screen?
- Customizing the WordPress login form
- How to display username and password after registration
- wp-login gives 404 error, but wp-admin is working fine
- Login error redirecting to wp-login page
- access the plugins for each role in WordPress multisite
- 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
- Why wp_update_user doesn’t update user_activation_key on users with apostrophes in their email?
- Forgot Password/ Password Reset Page does not exist
- WordPress on Apache behind nginx using letsencypt issue with loginizer/limit login attempts
- How to create user specific pages (not user role!)?
- Auto login between word press subdomain and a .net website
- Custom Login form from WordPress site to non-WordPress site
- Best option to implement external register/login to WP from self-made API
- Plugin creation – how to add user rights?
- Enqueue new login style sheet
- remove wp admin menu by customer user role
- Secure login on wordpress [closed]
- Login without Password
- Exclude login page from custom maintenance code
- Change default login auth
- I can’t access my WordPress dashboard – shows Warning message [closed]
- 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
- Sharing a logged in session with a custom subdmain site?
- MAMP localhost wordpress site, not possible to sign in, username and password are correct
- Login issues wordpress page
- 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?
- Login form does not store/remember/suggest users password
- Problem with is_user_logged_in() function in some pages
- 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
- Save user login date
- Login with Username (or Code) only
- 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
- each user having category with their name and can add sub categories post in that category
- Is there a way to give users the option to log in to their favorite group on login? [closed]
- Direct access to site when log in
- Can not login after moving to cloudflare and adding rules
- 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