Redirecting to home page after login as custom role WordPress

This is what I’m using, it redirects “shop_managers” to the admin orders page.

function my_login_redirect( $redirect_to, $request, $user ){
    if (isset($user->roles) && is_array($user->roles)) {
        if (in_array('shop_manager', $user->roles)) {
            $redirect_to = '/wp-admin/edit.php?post_type=shop_order';
        }
    }

    return $redirect_to;
}

add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

Obviously, you will need to change ‘shop_managers’ and ‘/wp-admin/edit.php?post_type=shop_order’ to what you need.

Tested and working.