I have a function which kind of works. It will not work the first time when cookies are cleared. But the next time I will get redirected after login. Why is that?
function role_user_redirect_login($username, $user){
if(array_key_exists('user', $user->caps)){
wp_redirect(admin_url('edit.php?post_type=test', 'https'), 301);
exit;
}
}
add_action('wp_login', 'role_user_redirect_login', 10, 2);