function wc_custom_user_redirect( $redirect, $user ) {
  $role = $user->roles[0];
  $dashboard = admin_url();
  $myaccount = get_permalink( wc_get_page_id( 'myaccount' ) );
  if( $role == 'administrator' ) {
    //Redirect administrators to the dashboard
    wp_redirect($dashboard);
    exit;
  } elseif ( $role == 'shop-manager' ) {
    //Redirect shop managers to the dashboard
    wp_redirect($dashboard);
    exit;
  } elseif ( $role == 'editor' ) {
    //Redirect editors to the dashboard
    wp_redirect($dashboard);
    exit;
  } elseif ( $role == 'author' ) {
    //Redirect authors to the dashboard
    wp_redirect($dashboard);
  } elseif ( $role == 'customer' || $role == 'subscriber') {
    wp_redirect(get_permalink(id));
    exit;
  } else {
    wp_redirect(get_permalink(id));
    exit;
  }
}
add_filter( 'wp_login', 'wc_custom_user_redirect', 10, 2 );