Sayyiduna Ibn Umar (may Allah be pleased with them both) said: The Messenger of Allah (peace and blessings be upon him) said: "When any of you is invited to a wedding feast, he should accept the invitation" (that is, he must go to it). Imam Darimi (may Allah have mercy on him) said: He should accept the invitation, but eating the food is not obligatory for him.
Hadith Referenceسنن دارمي / من كتاب النكاح / 2242
Hadith Gradingتحقیق (حسین سلیم أسد الدارانی):إسناده صحيح والحديث متفق عليه، [مكتبه الشامله نمبر: 2251]
Hadith Takhrijاس روایت کی سند صحیح اور حدیث متفق علیہ ہے۔ دیکھئے: [بخاري 5173] ، [مسلم 1429] ، [أبوداؤد 3736] ، [ابن حبان 5294]
Brief Explanation
(Commentary on Hadith 2241)
That is, you should participate, but due to a legitimate (shar‘i) reason, if you do not eat the food—such as if you see prohibited acts there, like gatherings of singing, music, and dancing, or if there is the serving of alcohol, or if you are eating a restricted (dietary) food—then eating is not obligatory.
And Allah knows best.
The aforementioned hadith declares it obligatory to accept the invitation of the wedding feast (walimah) on the occasion of marriage, and this is also the opinion of the majority of scholars (jumhur ulama).
They have certainly stipulated the condition that there should be no preventing factor in attending, for example, if the food itself is doubtful, or only the wealthy have been invited, or the invitation is for the purpose of cooperation and assistance in a wrongful act, or if there is something happening there which is disliked and falls under the definition of a prohibited act (munkar) according to the Shari‘ah—in such cases, there is no harm in not attending.
It is narrated in Sahih Muslim that when one of you is invited by his brother, he should accept his invitation, whether it is for a wedding or any other similar invitation. From this, it is also understood that one must attend the invitation.
It is also in Sahih Muslim: If you are observing a voluntary (nafl) fast, you should still attend the invitation, and you have the choice to eat or not eat. Similarly, the Prophet (sallallahu alayhi wa sallam) has, in numerous ahadith, commanded the acceptance of invitations.