Maʿālim al-Sunan 4/382:
“Beating the duff is not among the acts of worship upon which vows may legitimately be based. At best, it belongs to the category of what is merely permissible. However, once it became linked to openly celebrating the safe return of the Messenger of Allah—peace and blessings be upon him—when he entered Madinah after one of his expeditions, an event that grieved the unbelievers and humiliated the hypocrites, its practice acquired a status resembling certain supererogatory acts of devotion. For that reason, beating the duff was allowed.”
I say: This provides a strong indication that the incident was unique to the Prophet—peace and blessings be upon him; it is a specific occurrence without general applicability, as the jurists state in similar cases. Allah, exalted is He, knows best.