Madan Abu Talha reported,

Umar bin Khattab delivered a sermon one Friday in which he spoke of the Prophet of Allah ﷺ and of Abu Bakr. It was a long sermon, and toward its end he said, "People, you eat two plants that I can only regard as foul, this onion and garlic. I saw the Messenger of Allah ﷺ that whenever he detected their smell on a man, he would order him to be taken out to al-Baqi. So whoever eats them, let him kill their odor by cooking them."

Azami 7407

Sahih

عن معدان أبي طلحة

أن عمر بن الخطاب خطب يوم الجمعة، فذكر نبي الله ﷺ، وذكر أبا بكر- وذكر خطبة طويلة- قال في آخرها: ثم إنكم أيها الناس تأكلون شجرتين لا أراهما إلا خبيثتين، هذا البصل والثوم، لقد رأيت رسول الله ﷺ إذا وجد ريحهما من الرجل أمر به فأخرج إلى البقيع، فمن أكلهما فليمتهما طبخا.

الأعظمي 7407صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Foods
Chapter
Foods other than meat
Section
Eating garlic and onion when cooked
Numbering
Jami al-Kamil 7407 (2nd edition)
Azami 7407