It is narrated from Sulaiman bin Yasar (may Allah have mercy on him) that the Prophet (ﷺ) went towards Bi’r-e-Jamal to relieve himself. When he returned, a man greeted him with salam, but he did not reply until he wiped his hand on the wall, then he returned the greeting.
Hadith Referenceمسند الإمام الشافعي / كتاب الطهارة / 40
Hadith Takhrijمرسل، فإن سليمان بن يسار تابعي وشيخ الشافعي متروك الحديث، أخرجه البيهقي في معرفة السنن والآثار (120).