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 );