One who is used to drinking tea or coffee in the morning and whose mind remains unsettled without it, is permitted to drink it before prayer; his drinking does not possess pride, rather it is a necessity so that he can settle his mind and concentrate in prayer. There are some people who only feel a need to drink coffee two hours after they wake up, and therefore on weekdays when the prayer service is short, it is best that they do not drink coffee before praying. However, on Shabbatot and festivals, when the prayer service lasts a long time, it is better for them to drink coffee before prayer.
Someone who cannot drink coffee or tea without sugar is allowed to add a little sugar in order to drink and settle his mind. If he can suffice with artificial sweetener, that is preferable; however, he should not add milk. One who cannot drink coffee without milk and whose mind will not be settled without coffee is permitted to add milk to his coffee.
On Shabbat, many people are lenient and eat cake before the prayer service, but in actuality their custom is incorrect and they do not have on whom to base their practice. The only permissible consumption before prayer is coffee, for it is considered similar to water and because one who became accustomed to drink it has become addicted to caffeine and without drinking it, his mind is unsettled. However, eating cake is prohibited before prayer. Only someone who is so hungry that he cannot concentrate properly on his prayer, or one who thinks that later on he will be so hungry that his concentration will be disturbed, is permitted to be lenient and eat a small piece of cake before praying.
. Regarding coffee, see Mishnah Berurah 89:22, Yabia Omer, part 4, 11, and Ishei Yisrael 13:25. Concerning the consumption of cake before praying, although the Bei’urHalachah 89:3 s.v. “V’Chen” writes that it is preferable to pray individually and not eat before prayer, it seems that a distinction should be made between a set meal and a snack. If he must have a set meal, it is preferable that he prays individually and eats after that. However, if it is enough to eat a snack, it is best that he eat a little and then pray afterwards in a minyan. That is the difference between what I wrote here and what I wrote in the previous halachah.See Peninei Halachah Shabbat, part 1, 6:9, that according to many poskim, among them the Mishnah Berurah, Igrot Moshe, and Yalkut Yosef, one who eats before praying on Shabbat must recite Kiddush before he eats, although in practice, it is customary not to recite Kiddush before praying.