It is mentioned in Tadhkiratul-Auliya’ that there was a person who wanted to be considered trustworthy, pious, regular in prayers and an observer of fasts. He offered his prayers with this intention and performed virtuous deeds. However, wherever he went and whichever way he passed, people used to say look at this hypocrite who wishes to present himself as a pious man.
One day he thought, why am I ruining my hereafter. God knows when I will die, so why am I creating this curse for myself ? I have not offered even one prayer for the sake of God.
He wholeheartedly repented with genuine sincerity and truthfulness. He decided to perform all good deeds in secret and not to do anything to show off. This change was not verbal only; he began acting accordingly, and a pious change took place within him.
It is written that outwardly he made himself to appear as if he did not pray and that he was a dirty and wicked person. However, he engaged in virtuous deeds in secret. Wherever he went, adults and children started calling him a righteous and pious person; God’s beloved and chosen person.
The moral of this story is that true acceptance is bestowed from Heaven. The saints and pious people keep their good deeds a secret. They consider it a fault to disclose their faithfulness and truthfulness to others. However, sometimes they share certain necessary matters as permitted by Shariah or disclose some matters for educating others.
(Malfuzat, Vol. 5, p. 249–250)