Sahih al-Bukhari 1367
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
حَدَّثَنَا آدَمُ، حَدَّثَنَا شُعْبَةُ، حَدَّثَنَا عَبْدُ الْعَزِيزِ بْنُ صُهَيْبٍ، قَالَ سَمِعْتُ أَنَسَ بْنَ مَالِكٍ ـ رضى الله عنه ـ يَقُولُ مَرُّوا بِجَنَازَةٍ فَأَثْنَوْا عَلَيْهَا خَيْرًا، فَقَالَ النَّبِيُّ صلى الله عليه وسلم وَجَبَتْ ". ثُمَّ مَرُّوا بِأُخْرَى فَأَثْنَوْا عَلَيْهَا شَرًّا فَقَالَ " وَجَبَتْ ". فَقَالَ عُمَرُ بْنُ الْخَطَّابِ ـ رضى الله عنه ـ مَا وَجَبَتْ قَالَ " هَذَا أَثْنَيْتُمْ عَلَيْهِ خَيْرًا فَوَجَبَتْ لَهُ الْجَنَّةُ، وَهَذَا أَثْنَيْتُمْ عَلَيْهِ شَرًّا فَوَجَبَتْ لَهُ النَّارُ، أَنْتُمْ شُهَدَاءُ اللَّهِ فِي الأَرْضِ "."
Narrated Anas bin Malik:
A funeral procession passed and the people praised the deceased. The Prophet (ﷺ) said, "It has been affirmed to him." Then another funeral procession passed and the people spoke badly of the deceased. The Prophet (ﷺ) said, "It has been affirmed to him". `Umar bin Al-Khattab asked (Allah's Messenger (ﷺ) ), "What has been affirmed?" He replied, "You praised this, so Paradise has been affirmed to him; and you spoke badly of this, so Hell has been affirmed to him. You people are Allah's witnesses on earth."
Full reference and source
Sahih al-Bukhari 1367 In-book : Book 23, Hadith 120 USC-MSA web (English) : Vol. 2, Book 23, Hadith 448 (deprecated)
View source on Sunnah.com (opens in a new tab)