if ( is_user_logged_in() ) {
wp_redirect( home_url() );
}
function my_login_redirect( $url, $request, $user ){
if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
if( $user->has_cap( 'administrator') or $user->has_cap( 'author')) { $url = admin_url(); }
else { wp_redirect( home_url() ); }
}
}
add_filter('login_redirect', 'my_login_redirect', 10, 3 );