Umar bin Khattab delivered a Friday sermon in which he said, "People, you eat two plants that I consider nothing but foul, this onion and garlic. I saw the Messenger of Allah ﷺ, whenever he detected their smell on a man in the mosque, order him to be taken out to al-Baqi. So whoever eats them, let him kill their odor by cooking."
قال ان عمر بن الخطاب، خطب يوم الجمعة فقال: ايها الناس تأكلون شجرتين لا اراهما الا خبيثتين. هذا البصل والثوم. لقد رأيت رسول الله ﷺ اذا وجد ريحهما من الرجل في المسجد، امر به فأخرج الي البقيع، فمن اكلهما فليمتهما طبخا.
Muslim narrated it in "The Mosques" (567) from Muhammad bin Muthanna, who said, "Yahya bin Saeed narrated to us, Hisham narrated to us, Qatada narrated to us, from Salim bin Abu Jaad, from Madan bin Abu Talha, from Umar bin Khattab," and he related it in a long hadith.