أَخْبَرَنِي زِيَادُ بْنُ أَيُّوبَ، قَالَ حَدَّثَنَا إِسْمَاعِيلُ، قَالَ حَدَّثَنَا عَبْدُ الْعَزِيزِ، عَنْ أَنَسٍ، قَالَ مُرَّ بِجَنَازَةٍ فَأُثْنِيَ عَلَيْهَا خَيْرًا فَقَالَ النَّبِيُّ صلى الله عليه وسلم ‏"‏ وَجَبَتْ ‏"‏ ‏.‏ وَمُرَّ بِجَنَازَةٍ أُخْرَى فَأُثْنِيَ عَلَيْهَا شَرًّا فَقَالَ النَّبِيُّ صلى الله عليه وسلم ‏"‏ وَجَبَتْ ‏"‏ ‏.‏ فَقَالَ عُمَرُ فِدَاكَ أَبِي وَأُمِّي مُرَّ بِجَنَازَةِ فَأُثْنِيَ عَلَيْهَا خَيْرًا فَقُلْتَ ‏"‏ وَجَبَتْ ‏"‏ ‏.‏ وَمُرَّ بِجَنَازَةٍ فَأُثْنِيَ عَلَيْهَا شَرًّا فَقُلْتَ ‏"‏ وَجَبَتْ ‏"‏ ‏.‏ فَقَالَ ‏"‏ مَنْ أَثْنَيْتُمْ عَلَيْهِ خَيْرًا وَجَبَتْ لَهُ الْجَنَّةُ وَمَنْ أَثْنَيْتُمْ عَلَيْهِ شَرًّا وَجَبَتْ لَهُ النَّارُ أَنْتُمْ شُهَدَاءُ اللَّهِ فِي الأَرْضِ ‏"‏ ‏.‏

It was narrated that Anas said: "A funeral passed by and the deceased was praised." The Prophet said: "It is granted." Another funeral passed by and the deceased was criticized. The Prophet said: "It is granted." 'Umar said: "May my father and mother be ransomed for you. One funeral passed by and the deceased was praised, and you said, 'It is granted?"' He said: "Whoever is praised will be granted Paradise, and whoever is criticized will be granted Hell, You are the witnesses of Allah on Earth." Translation Not Available

Book Ref: Sunan An Nisai Book 21 Hadith 1932
Web Ref:  Sunan An Nisai Vol 3 Book 21 Hadith 1934