No, this is not legal as written. This is really a series of three separate trades (one of them being with the bank), and two of them are giving a resource for free, which is forbidden by the rules.
The problem is that a trade can only involve 2 people, so a "triangular trade" must be done as separate trades. From the FAQ:
Trade - Is a “triangular trade” permitted? On player A’s turn, are player B and player C allowed to trade with each other if afterwards one of them uses the obtained resource for trading with player A?
No. Not only is a triangular trade forbidden, it is also unnecessary, because player B and player C each trades individually with player A and, thus, may trade whatever resource he has – provided that it meets the requirements of player A.
And:
Trade - May I give away resources or buy services with them, for example, to avoid being bothered by the robber?
No. On Catan, a trade always involves giving and taking resources. Consequently, Catan’s trade law does not contain a “trade” of something for nothing or for immaterial goods such as services.
If they really want to do this, and they trust each other, they can do the following trades:
- A gives 3 wheat and gets 1 ore
- B gives 4 wheat and gets 1 ore
- A trades 4 wheat to the bank for 1 brick
- A gives 1 brick and gets 1 ore
Those are 4 separate, legal trades that have the same result. But there's nothing stopping either player from choosing to stop after any given step; though doing so will hurt their chances of being trusted in future trades and even future games.