The author - may Allah shower blessings on him- cited this chapter regarding some rulings relating to the mosque. It is forbidden for one who eats onion, garlic, leek or other similar substance to come close to the mosque or enter it until the odour (of the onion or the garlic) goes away.
Then he- may Allah shower blessings on him- mentioned many hadeeths, one of which is the hadeeth of Umar bin Khattaab (may Allah be pleased with him). He said in the sermon of Friday Prayer: “O you people! You eat garlic and onion. I consider the odour of these two to be very offensive.” And he (Umar) narrated that if a man enters the mosque after eating any of these substances, the Prophet ﷺ would order that that person should be taken to Al-Baqee’. This was a well-known place close to the mosque of the Prophet ﷺ. The act of taking the person to Al-Baqee’ serves as a punishment; otherwise, it would have been sufficient to take him out of the mosque. However, he is taken to Al-Baqee to serve as a deterrent.
However, Umar (may Allah be pleased with him) said: ‘He who wants to eat any of these (i.e. garlic and onion) should cook them till their odour dies out.
It is derived from this hadeeth that garlic and onion are not unlawful. One is allowed to eat them but when one eats them, one should not enter the mosque, pray with the congregation or attend
lectures because the angels would be harmed by their offensive odour.
Scholars also say that the one that has mouth odour or bad breath should not come to the mosque until such odour dies out. This is because the wisdom behind the prohibition of garlic exists in his case, which is offending the angels with offensive odour.
But if it is asked: What if someone uses what will take away the odour, can he enter the mosque? We will reply: Yes, if he eats something that completely neutralizes the offensive odour. This is because the application or deferral of a ruling conforms with the presence or absence of its cause.
If a person were to ask: Can someone (purposely) eat them in order to avoid going to the mosque? We will say, no, it is not permissible for a person to look for a way of avoiding an obligation. However, if he eats them because he desires to eat them, the eating is lawful but he should stay away from the mosque until the odour disappears.