cursed women who visit graves and those who erect places of worship over them or install lamps upon them.”
However, this woman had not gone out with the intention of visiting the grave. She was driven only by the searing pain of separation from her child and by overwhelming grief; she simply could not keep herself from coming. For that reason the Prophet ﷺ excused her, did not remove her by force, and did not compel her to return home.
Among the lessons of this ḥadīth is that a person is excused when acting out of ignorance, whether it is ignorance of the legal ruling or ignorance of the situation itself. This woman said to the Prophet ﷺ, ilayka ʿannī—“Keep away from me!”—even though he was commanding her to righteousness, God-consciousness, and patience. Because she did not realize that the one addressing her was the Messenger of Allah ﷺ, he pardoned her.
Another benefit: someone charged with attending to the needs of the Muslims should not station a doorkeeper at his house who blocks people if those people truly need him. The exception is when the sheer number of visitors would overburden him, distract him, or disrupt tasks that can be dealt with at another time; in that case, placing a gatekeeper is acceptable.