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
- WordPress change role from administrator to author by itself (automatically)
- In Django, how do I know the currently logged-in user?
- Can I programmatically login a user without a password?
- Allow member to have access to custom post type only. Permission to only edit their own posts
- Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
- Is there any way to rename or hide wp-login.php?
- How to login with email only no username?
- How can I redirect user after entering wrong password?
- Increase of failed login attempts, brute force attacks? [closed]
- Login page ERROR: Cookies are blocked due to unexpected output
- SSO / authentication integration with external ‘directory service’
- Preventing session timeout
- How reduce wordpress login session timeout time?
- How to prefill WordPress registration with social details
- Check for correct username on custom login form
- I can’t access my site via wp-admin
- ‘Password field is empty’ error when using autofill in Chrome
- Removing username from the ‘wordpress_logged_in’ cookie
- How to show ‘login error’ and ‘lost password’ on my template page?
- What is $interim_login?
- Custom login form
- How to prefill the username/password fields on the login page
- wp_signon returns user, but the user is not logged in
- wp_update_user not updating
- Adding extra authentication field in login page
- Prevent wp_login_form() from redirecting to wp-admin when there are errors
- Allowing users to edit only their page and nobody else’s
- Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
- wp_signon() does not authenticate user guidance needed
- What exactly is ReAuth?
- What are the differences between wp_users and wp_usermeta tables?
- Login members using web services
- Make my wordpress blog remember my login “forever”
- Troubleshooting a “You do not have sufficient permissions to access this page” error
- How to check in timber if user is loggedin?
- Restrict admin access to certain pages for certain users
- How do I change the language of only the login page?
- How can I hide a category from Contributors in the edit/add new post screen?
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- Disable WordPress 3.6 idle logout / login modal window / session expiration
- Stop WordPress from logging me out (need to keep me logged in)
- Woocommerce registration page [closed]
- How to disable autocomplete on the wp-login.php page
- Share login data/cookies between multiple installations
- How to assign specific users the capability to edit specific pages / posts / custom post types
- Hide Admin Menu for Specific User ID who has administrator Role
- Synchronize WordPress user accounts across multiple domains and installations without using WordPress MU
- How to pass users back and forth using session data?
- How do I change the logo on the login page?
- Why does WordPress hide the reset password key from the URL?
- Is it possible to sign in with user_email in WordPress?
- How to get all capabilities of an existing user role
- How to use current_user_can()?
- Avoid to load default WP styles in login screen
- WordPress registration message
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- How to fake a WordPress login?
- Limit access to posts/pages by user roles
- how to display the wordpress login and register forms on a page?
- Does wp_logout_url() destroy a session? (Logging out question)
- 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
- Is WordPress’ is_user_logged_in() secure?
- How can i increase the login expiration length?
- How do I use add_action from a class method?
- How to remove the WordPress logo from login and register page?
- How can I add a custom script to footer of login page?
- Brute force attack?
- Customize wp_new_user_notification_email()
- Need to execute a cron job
- Login email after registration never sent or received