It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever eats these two plants, garlic and onion, must not come near our place of prayer; and let him come to me so that I may pass my blessed hand over his face and seek Allah's protection for him." I say: This hadith is in the two Sahihs (Bukhari and Muslim), except for his (peace and blessings be upon him) words: "And let him come to me so that I may pass my hand over his face and seek Allah's protection for him." Imam al-Tabarani also narrated it with this wording, that the Messenger of Allah (peace and blessings be upon him) said: "Beware of eating these two foul-smelling vegetables and then entering our mosques; if you must eat them, then first kill their smell with fire (by cooking them)."
Hadith Referenceإتحاف الخيرة المهرة بزوائد المسانيد العشرة / كتاب المساجد / 1024
Hadith Gradingمحدثین:أصله في الصحيحين
Hadith Takhrij«أخرجه المعجم الأوسط للطبراني برقم: 3668، وأخرجه مجمع الزوائد ومنبع الفوائد برقم: 1994، وأخرجه الأحاديث المختارة برقم: 1740»