The Acceptable Action
Sheikh Muhammad Nasirud-Din al-Albani
Therefore, in these Ahadith, the Prophet (Peace and blessings be upon him) encouraged us to make our actions righteous, whether gaining wealth or other things. However, we must remember a certain fact about this action, a fact that many people neglect. The explanation of this fact should actually be a complete lesson in itself; and it is that only a righteous action is beneficial, not just any action.
So what are the conditions that a Muslim must fulfill in order for the action to be righteous? This is shown in the statement of Allah - the Exalted and Sublime:
"Say (O Muhammad): Verily I am only a man like yourselves, but revelation has been revealed to me that the One whom you should worship is only One Deity. And whoever hopes to meet his Lord, let him do righteous actions; and in the worship of your Lord, do not associate anyone along with Him."
Two Important Conditions
The Scholars of Tafsir have said that the end of this verse is an indication that there are two conditions for an action to be righteous and acceptable: 
Firstly: That the action must be in accordance with the Sunnah. Therefore, if the action is done as an act of worship, but is not in accordance with the Sunnah, it is not a righteous action. The reason is that compliance with the Sunnah is one of the conditions for the action's righteousness. The proofs of this are many, but it is enough to state one:
The Hadith of the Prophet (Peace and blessings be upon him) in which he said:
"Whoever innovates in this matter of ours what is not upon it, it shall be rejected." 
Therefore, any action that was not part of Islam when Allah revealed it upon the heart of the Prophet Muhammad (Peace and blessings be upon him) is not a righteous action. About this, Allah - the Most High - says:
"This day I have perfected your Deen for you and completed My favor upon you and I have chosen Islam as your Deen."
It must be remembered that Bid'ah (innovation)  is not divided into five categories, as some Scholars say.
A proof for this is that the Prophet (Peace and blessings be upon him) said:
"Every innovation is misguidance, and every misguidance is in the Hellfire." 
That after being in accordance with the Sunnah, the action has to be sincere, purely seeking the Face of Allah - the Most High - because Allah says at the end of the aforementioned verse:
"And in the worship of your Lord, do not associate anyone along with Him."
This means that the person seeks, by his righteous action, only the Face of Allah - the Exalted and Sublime.
However, if he seeks other than Allah, then he has setup partners with Allah (made Shirk with Allah), therefore his action is rejected.
This is confirmed by Allah in an authentic Hadith Qudsi:
"I am so self-sufficient that I am in no need of having any partners. Thus, whosoever does an action for the sake of someone else as well as Me, will have that action rejected by Me, to him whom he associated with Me." 
Consequently, if the action is righteous but not sincere for the sake of Allah's Face, it is rejected. Moreover, if the action is purely for the sake of Allah's Face, but not in accordance with the Sunnah, it is likewise not accepted.