1add_filter( 'login_redirect', 'login_redirect_shop_manager_on_orders_list', 10, 3 );
2function login_redirect_shop_manager_on_orders_list( $redirect_to, $request, $user ) {
3 $defined_user_role = 'shop_manager'; // The defined user role
4
5 if( isset($user->roles) && is_array($user->roles) && in_array( $defined_user_role, $user->roles ) ) {
6 $redirect_to = admin_url('edit.php?post_type=shop_order'); // Custom redirection url
7
8 wp_safe_redirect( $redirect_to ); // Force redirection
9 exit(); // Mandatory to avoid errors
10 }
11 return $redirect_to;
12}
13