`Ali (May Allah be pleased with him) reported:
We were accompanying a funeral procession in Baqi` Al-Gharqad (graveyard in Al-Madinah) when the Messenger of Allah (ﷺ) proceeded towards us and sat down. We sat around him. He had a small stick in his hand. He was bending down his head and scraping the ground with the stick. He said, “There is none among you but has a place assigned for him either in the Jannah or in the Hell.” The Companions said: “O Messenger of Allah, should we not depend upon what has been written for us (and give up doing good deeds)?” The Messenger of Allah (ﷺ) said, “Carry on doing good deeds. Every one will find it easy to do such deeds (as will lead him to his destined place) for which he has been created.”
Reported by Imam Al Bukhari and Muslim.
Shaykh Al Uthaymeen رحمه الله said:
This is the admonition by the grave. That is, if the person when he sits (and) the people sit around him, he takes advantage of this moment by reminding. As for that he stands by the grave and speaks as if he is giving a sermon, then this wasn’t from the guidance of the messenger صلى الله عليه و سلم.
(It wasn’t from his guidance) that the person stand between the people, between the audience and start speaking with a loud speech as if he was giving a sermon.
This isn’t from the Sunnah; rather the Sunnah is that you only do as the messenger صلى الله عليه و سلم did. If the people are sitting and the deceased hasn’t been buried, then sit in waiting for his burial and speak the speech of the sittings, and it is ordinary speech, not like a sermon.
Some of the people have taken from this chapter heading, this chapter heading of An Nawawi and from before him the chapter heading it Al Bukhari in his Saheeh “Chapter: The admonition by the grave” that he be a preacher amongst the people. Also (they took from it) that he preach with a loud voice, (such as saying) “Oh Slaves of Allah”, and similar to that from statements which are said in the Khutbah, and this is a mistaken understanding, not correct.
Thus the admonition by the grave is specified with that which has come in the Sunnah so that the graveyards aren’t taken as platforms in which sermons are given by it such as the Friday sermon. Rather, (it should be a) calm admonition in which a person is sitting and the signs of sadness and contemplation and similar to that are apparent on him.
Not the signs of courageousness as if he is warning an army, “the enemy is coming to attack you in the morning and in the evening”.
Rather, Allah gives his bounty to whom ever he wills. Thus some people understand something from the texts an understanding which isn’t intended by it and Allah guides whom ever He wants to the straight path.
Also from that which is not befitting to be done is that some people when they are waiting for the burial, you find them gathered in groups and speaking as they would in the sittings, whereas some of them you might even hear a giggle from him and similar to that, and this is a mistake. This is not the place for it.
For that reason, they say it’s befitting for the person attending the burial that he be composed, and that he ponder in regards to his abode and that right now he is waiting for the burial of this deceased one and tomorrow the people will be waiting for his burial. As he buried others, he will (also) be buried!
[Sharh Riyadus Saliheen 4/559-560]
Majid Jawed Al-Afghanee