A funeral procession passed by, and the people praised the deceased. The Prophet ﷺ said, "It is confirmed."Then another funeral procession passed by, and the people spoke ill of the deceased. The Prophet ﷺ said, "It is confirmed."Umar said, "May my father and mother be ransomed for you. A funeral passed by and the people praised the deceased, and you said, 'It is confirmed.' Then another funeral passed by and the people spoke ill of the deceased, and you said, 'It is confirmed.'"The Prophet ﷺ replied, "Whoever you praised, Paradise has been confirmed for him, and whoever you spoke ill of, the Fire has been confirmed for him. You are Allah's witnesses on earth."
أخبرني زياد بن أيوب قال حدثنا إسمعيل قال حدثنا عبد العزيز
مر بجنازة فأثني عليها خيرا فقال النبي ﷺ وجبت ومر بجنازة أخرى فأثني عليها شرا فقال النبي ﷺ وجبت فقال عمر فداك أبي وأمي مر بجنازة فأثني عليها خيرا فقلت وجبت ومر بجنازة فأثني عليها شرا فقلت وجبت فقال من أثنيتم عليه خيرا وجبت له الجنة ومن أثنيتم عليه شرا وجبت له النار أنتم شهداء الله في الأرض
Muslim narrated it in the chapter on funerals, in the section on those deceased who are praised as good or bad, hadith no. 949, from the hadith of Ismail bin Ulaya, and Bukhari, in the chapter on funerals, in the section on people's praise of the deceased, hadith no. 1367, from the hadith of Abdul-Aziz bin Suhayb, with the same wording. It is also found in al-Kubra, hadith no. 2059.