I heard the Messenger of Allah ﷺ say, "Command what is right and forbid what is wrong before you call upon Allah and find your prayers unanswered."
حدثنا أبو بكر بن أبي شيبة حدثنا معاوية بن هشام عن هشام بن سعد عن عمرو بن عثمان عن عاصم بن عمر بن عثمان عن عروة
سمعت رسول الله ﷺ يقول مروا بالمعروف وانهوا عن المنكر قبل أن تدعوا فلا يستجاب لكم
[Hasan] Bayhaqi narrated it, 10/93, from the hadith of Hisham bin Saad with this wording, and Ibn Hibban graded it sahih. Asim bin Umar is majhul, and his hadith has corroborating narrations in Tabarani's Awsat, 2/217, no. 1389, and Khatib, 13/920, and others.