It is narrated from ‘Adi bin Hatim (may Allah be pleased with him), he states that a man delivered a sermon before the Prophet ﷺ and said: “Whoever obeys Allah and His Messenger has found guidance, and whoever disobeys both of them has gone astray.” So the Messenger of Allah ﷺ said: “Be quiet, you are a bad orator.” Then the Messenger of Allah ﷺ (delivered the sermon and) said: “Whoever obeys Allah and His Messenger has found guidance, and whoever disobeys Allah and His Messenger ﷺ has gone astray.” Then he said to that man: “Do not say: ‘whoever disobeys both of them.’”
Hadith Referenceمسند الإمام الشافعي / كتاب الجمعة / 446
Hadith Takhrijصحيح من غير هذا الطريق: اخرجـہ مسلم، الجمعۃ، باب تخفيف الصلاة والخطبة، رقم: 870۔