Assalaamu alaykum. If the administrative committee or authority of a mosque puts up a poster which has written on it, “No eating or drinking in the mosque except for Iftaar (pre-dawn meal taken before fasting) and Suhoor (braking the fast)” (or words to that effect), then does that make it haram to eat in the mosque at times other than Iftaar and Suhoorl, or does the basic principle of the permissibility of eating and drinking in the mosque still remain?
All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
If there is a preponderant benefit in this matter, then it is an obligation to abide by it, as the ruling revolves around the benefit (interest); the Shariah of Allah is always with the benefit.
Therefore, if the people in charge of the mosque assigned these two times because there are workers to clean the mosque present then and they forbade eating at other times, then it is an obligation to abide by this because of the benefit.
However, if there is no preponderant benefit, then it is not an obligation to abide by it. Rather, it is permissible to eat at all times while being keen on preserving the cleanliness of the mosque.
Ibn Taymiyyah said in the Egyptian Fataawa, “Eating and sleeping in the mosque is acceptable as long as this does not become a habit.”
“Ash-Shaafi'i and the scholars of his School said, ‘It is permissible for the person observing I’tikaaf (seclusion in the mosque for the purpose of worship) and others to eat and drink in the mosque and spread the table, and to wash his hands provided that no one is harmed by his washing. However, if he washes his hands inside a container, then this is better. The evidence of the scholars is derived from the Book of Allah. The scholars of our School (Shaafi’i) said: 'It is desirable for the person who eats to spread a tablecloth or the like in order to preserve the cleanliness of the mosque.'’”
Kash-shaaf al-Qinaa’ reads, “It is acceptable for a person observing I’tikaaf and others to eat in the mosque, as ‘Abdullah ibn Al-Haarith narrated, ‘We used to eat bread and meat in the mosque during the time of the Prophet .’” [Ibn Maajah]
Shaykh Ibn Baaz said:
“There is nothing wrong with sleeping and eating in the mosque for the person observing I'tikaaf and others, because of the ahaadeeth and statements (of the Companions) that were mentioned in this regard, as it is confirmed that the people of the Suffah (i.e. the poor who used to live in the Prophet's mosque) used to do so [in one of the corners or side of the mosque]; while taking the cleanliness of the mosque into consideration and being careful not to make it dirty with the leftovers, as the Prophet said, ‘The rewards of my people were presented before me, so much so that even the reward for removing a mote (speck of dirt) from the mosque was presented to me.’ [Abu Daawood and At-Tirmithi, and Ibn Khuzaymah graded it as Saheeh (sound)]
‘Aa’ishah, may Allah be pleased with her, also narrated, ‘The Prophet ordered that the mosques be built in districts and that they be kept clean and scented.’ [Abu Daawood, At-Tirmithi, Ibn Maajah, Ahmad; its chain of narrators is classified as Good.]”
Allah knows best.
You can search for fatwa through many choices