The Messenger of Allah ﷺ said, "Whoever enters this mosque of mine to learn something good or to teach it is like a warrior striving in the path of Allah Almighty, and whoever enters it for any other purpose is like one who sees something that pleases him while it belongs to someone else."
قال رسول الله ﷺ: من دخل مسجدي هذا يتعلم خيرا، أو يعلمه كان كالمجاهد في سبيل الله تعالى، ومن دخله لغير ذلك كان كمنزلة الذي يرى الشيء يعجبه وهو لغيره.
Tabarani narrated it in Al-Kabir (6/215), and Abu Naeem in Al-Hilya (3/254) — and the wording is his — both of them through the route of Yaqub bin Humayd bin Kasib, who said, Abdul-Aziz bin Abu Hazim narrated to us, from his father, from Sahl bin Saad Saadi, and he related the hadith.Abu Naeem said, "This is a rare hadith from the hadith of Abu Hazim, from Sahl bin Saad, his son Abdul-Aziz alone transmitted it from him."I say, Abdul-Aziz bin Abu Hazim is trustworthy and a jurist, Ibn Main and Nasai both declared him trustworthy, so his being the sole transmitter does not harm the hadith, especially in his narration from his father. Imam Ahmad said, "He was not known for seeking out hadith except through his father's books, for they say he heard them from him, and he was learned in jurisprudence, there was no one in Madinah after Malik more learned in jurisprudence than him."However, in the chain there is Yaqub bin Humayd bin Kasib, concerning whom there is disagreement. Ibn Main said once, "Trustworthy," and another time, "There is no harm in him." Abu Hatim, Nasai, and others declared him daif. But Bukhari said, "He has continued to be good, he is originally truthful (saduq)." And Ibn Adi said, "There is no harm in him or in his narrations, and he has a great deal of hadith and a great deal of rare reports."I say, the summary regarding him is that if his hadith has a basis, then it is hasan al-hadith, and this is one of them.