Imam Khomeini explains the matter in his famous work of "an exposition on Forty Hadith" as following:
Zurarah reports that he questioned Imam al-Baqir (peace be upon him) about the status of a person who performed good deeds, which were seen by others and it made him happy. Said the Imam (A): There is no harm in it; there is no one who does not like that his good deeds be made known to the people, in case he does not perform them [solely] for the sake of attracting their admiration.
In one of the two ahadith, the tendency of performing good deeds for the sake of earning respect and admiration is considered as the sign of riya’, while in another hadith it is stated that there is no harm in the joy resulting from the demonstration of a good deed. These two different positions are taken in view of the category to which an individual belongs.
There are certain other reasons also for such a view, but we shall abstain from mentioning them.
At the end, it is to be noted that sum’ah means to orally transmit one’s good qualities to the ears of people for the purpose of attracting them and publicizing oneself, and this tendency is a branch of the vicious tree of riya’. For the same reason we have dealt with sum’ah as a part of riya’, not as a distinct vice, and have not elaborated its meaning separately.
Imam Khomeini always addressing faithful people said: Purify your inner self so that your actions also will be pure and untainted by the love of the world or hatred of fellow beings; your spirit should be pure and untainted and all the infirmities and corruptions of the soul should be eliminated.
Read more: