Praise be to Allah.
If this Muslim man died and the funeral prayer was not offered for him, then it must be offered for him now, either by going to his grave, which is just for men, so one or more men may go to his grave and offer the funeral prayer there; or by offering the funeral prayer in absentia for him (salaat al-ghaa’ib), in which both men and women may take part. This prayer may be done anywhere; they may offer the prayer in the mosque or in a house, and they should form rows as if the bier is in front of them.
That is because offering the funeral prayer for the deceased is obligatory. The evidence for that includes the hadeeth narrated in Saheeh al-Bukhaari (2176) and Saheeh Muslim (1619) from Abu Hurayrah, which says that when a dead man who had a debt was brought to him, the Messenger of Allaah (peace and blessings of Allaah be upon him) would ask, “Did he leave behind anything with which to pay off his debt?” If he had left something behind, then he would offer the funeral prayer for him, otherwise he would say, “Offer the funeral prayer for your companion.” When Allaah enabled him to conquer other lands, he said, “I am closer to the believers than their own selves (cf. al-Ahzaab 33:6). Whoever dies in debt, I will repay it and whoever leaves behind wealth, it is for his heirs.”
But the funeral prayer is a communal obligation (fard kifaayah); if enough people undertake this duty, then the rest of the Muslims are absolved of blame.
It was narrated by al-Bukhaari (1337) and Muslim (956) from Abu Hurayrah that a black person – a man or a woman – who used to clean the mosque died, and the Prophet (peace and blessings of Allaah be upon him) did not know of the death. He mentioned him (or her) one day and he asked, “What happened to that person?” They said “He (or she) died, O Messenger of Allaah.” He said, “Why did you not tell me?” They said ... (as if they thought the matter was not important enough to tell the Prophet (peace and blessings of Allaah be upon him) about). He said, “Show me where his (or her) grave is,” and he went to the grave and offered the funeral prayer.
This indicates that it is permissible to offer the funeral prayer for the deceased after the burial.
It was narrated by al-Bukhaari (1333) and Muslim (951) from Abu Hurayrah that the Messenger of Allaah (peace and blessings of Allaah be upon him) announced the death of the Negus the day he died, and he took the people out to the musalla (prayer place), lined them up in rows and pronounced four Takbeers (i.e., the funeral prayer).
This hadeeth indicates that it is permissible to offer the funeral prayer in absentia. Some scholars restricted this to one for whom the funeral prayer has not been offered, and others restricted it to scholars and virtuous people.
From the texts quoted above we learn what we stated at the beginning of this answer. The scholars have stated that if the deceased has been buried and the prayer has not been offered for him, it should be offered after the burial. Shaykh Ibn ‘Uthaymeen said: If the funeral prayer has not been offered for him, we should offer it even if that is several years later.
Al-Sharh al-Mumti’, 5/440
The Standing Committee was asked the following question:
A child of mine died at the age of six months, and he was taken to the graveyard and buried without me offering the funeral prayer for him because I forgot. I do not know where the grave is in which the child was buried. Is there any act of charity that will make up for the prayer, or any other act that will make up for the prayer?
The Committee answered:
There is no other act that will make up for the funeral prayer for the deceased, whether he was a child or an adult, whether an act of charity or any other righteous deed. You have to go to the graveyard where he is buried, and stand with the graveyard between you and the qiblah, then offer the funeral prayer for this child, in a state of purity (i.e., with wudoo’) and fulfilling all the conditions of prayer. That will be sufficient, since you do not know exactly where the child’s grave is. Allaah says (interpretation of the meaning):
“Allaah burdens not a person beyond his scope”
“So keep your duty to Allaah and fear Him as much as you can”
And the Prophet (peace and blessings of Allaah be upon him) said: “If I command you to do a thing, then do as much of it as you can, and if I forbid you to do a thing, then avoid it.” And Allaah is the source of strength.
Fataawa Islamiyyah, 1/27
And Allaah knows best.
See al-Insaaf by al-Mirdaawi, 2/471; Manah al-Shaafiyaat by al-Bahooti, 1/171 .