All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
It is an indisputably established fact that only Allaah The Almighty can bring about benefit or cause harm, and a person who believes that the dead are able to do this thereby associates others with Allaah. Allaah ordered the Prophet to announce to all people that he was not able to bring about any benefit or harm himself, except that which Allaah had willed. Allaah the Almighty Says: (what means): {Say, "I do not own for myself [the power of] benefit or harm, except what Allaah has willed. And if I could foresee the unseen, I would have done much good.} [Quran 7:188]
The Prophet explained to Ibn ‘Abbaas that if the Muslim nation were to unite to benefit him, they could only do what Allaah had preordained for him anyway, and if they were to unite to harm him, they could only harm him with what Allaah had preordained for him anyway. [At-Tirmithi and Ahmad]
A person who believes that the living or the dead can cause others benefit or harm without the permission or will of Allaah, has turned into a disbeliever, Allaah forbid. The same also applies to anybody who supplicates to the dead or seeks their pleasure by slaughtering animals or making vows to them, even if the person does not believe that they can provide benefit or cause harm.
It is a disputable issue among scholars if the man in question slaughters goats for the sake of Allaah the Almighty and in His Name, while giving away their meat as charity.. In this case the meat is lawful and there is no doubt about it. However, this rule does not apply to the slaughterer of the goats in this case for certain reasons:
If this man slaughters the goats in the name of those people, it will be Shirk (disbelief) that expels him from Islam, Allaah forbid. Ar-Raafi‘i quoted Imaam An-Nawawi as stating that slaughtering animals for the sake of the being that is worshiped is similar to prostrating to it. Each behavior constitutes a form of veneration and an act of worship that should be dedicated to Allaah the Almighty alone, the only One worthy of worship. Thus, it is prohibited to eat from the meat of an animal that somebody has slaughtered for the sake of anyone other than Allaah, either to a living being or an inanimate object, like an idol. This action is an act of disbelief, similar to the act of prostrating in worship to beings other than Allaah. The same applies to slaughtering animals for anyone other than Allaah.
Ibn Taymiyyah mentioned that slaughtering animals to Allaah is the highest form of humility and submission to Him. Therefore, it is not permissible to do this for anyone other than Allaah, nor is it permissible to mention any name other than His Name while slaughtering the animal. The person who practices such a heinous act will be cursed, as the Prophet said that Allaah the Almighty curses anyone who slaughters animals for other than Him. [Muslim, An-Nasaa'i and Ahmad]. So in sum, it is not allowed for you to eat the meat of these slaughtered animals.
Similarly, if this person slaughters animals for these people out of veneration for them and his intention, deep in his heart, is to slaughter the animals for their sake but he mentions the Name of Allaah while slaughtering, it still is not permissible to eat this meat. The belief of this man is corrupt and the act is major Shirk that expels him totally from Islam. Thus the animals he slaughtered take on the same rule as animals slaughtered by an apostate, the consumption of which is prohibited even if the Name of Allaah is mentioned while slaughtering it.
Allaah Knows best.