What Happens If You Eat Prohibited Food?
Question

Is it true that if you eat Haram food your prayer does not get accepted for 40 days?
Praise be to Allah.If you eat prohibited food, this will cause your Du`a to be rejected . The Prophet (peace and blessings be upon him) said: “Allah is Good and does not accept anything but that which is good. Allah has enjoined upon the believers that which He enjoined upon the Messengers.” Allah says (interpretation of the meaning): 
“O you who believe (in the Oneness of Allah — Islamic Monotheism)! Eat of the lawful things that We have provided you with, and be grateful to Allah.” [Al-Baqarah 2:172]
And He says (interpretation of the meaning): 
“O (you) Messengers! Eat all kinds of lawful foods which Allah has made lawful (meat of slaughtered eatable animals, milk products, fats, vegetables, fruits)] and do righteous deeds.” [Al-Mu’minun 23:51]
Then he (peace and blessings be upon him) mentioned a man who travels a great deal and becomes disheveled and covered with dust, who raises his hands to the heavens (and says), ‘O Lord, O Lord,’ when his food is prohibited, his drink is prohibited, his clothes are prohibited and he has been nourished with prohibited, so how can he receive a response?  (Narrated by Muslim) 
The meaning is that it is unlikely that his Du`a will be answered . But prayer, which includes Du`a and other things, will still be accepted, in the sense that it serves to fulfill his obligations, and he does not have to repeat it. What was narrated was that it is the one who drinks alcohol whose prayer will not be accepted for forty days .
For more details, please refer to the following answers: 49688 , 71 , 59899 , and 231261 .
And Allah knows best.