Praise be to Allah.
For acts of worship to be acceptable to Allah and for a person to be rewarded for them, there are two conditions which must be met:
The first condition: the act of worship should be devoted to Allah Alone. Allah says (interpretation of the meaning):
“And they were commanded not, but that they should worship Allah, and worship none but Him Alone (abstaining from ascribing partners to Him).”
The meaning of worshipping Allah alone is that the person should intend in all his words and deeds, both inward and outward, to seek the Face of Allah (i.e., His pleasure). Allah says (interpretation of the meaning):
“And who has (in mind) no favour from anyone to be paid back,
Except to seek the Countenance of his Lord, the Most High.”
“(Saying): “We feed you seeking Allah’s Countenance only. We wish for no reward, nor thanks from you.”
“Whosoever desires (by his deeds) the reward of the Hereafter, We give him increase in his reward, and whosoever desires the reward of this world (by his deeds), We give him thereof (what is decreed for him), and he has no portion in the Hereafter.”
“Whosoever desires the life of the world and its glitter, to them We shall pay in full (the wages of) their deeds therein, and they will have no diminution therein.
They are those for whom there is nothing in the Hereafter but Fire, and vain are the deeds they did therein. And of no effect is that which they used to do.”
It was narrated that ‘Umar ibn al-Khattab (may Allah be pleased with him) said: “I heard the Messenger of Allah (peace and blessings of Allah be upon him) say:
‘The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrated for worldly benefits or to marry a woman, his emigration was for what he emigrated for.’”
(Narrated by al-Bukhari, Bad’ al-Wahy, 1).
It was narrated by Muslim from Abu Hurayrah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings of Allah be upon him) said: “Allah, may He be blessed and exalted, says: ‘I am so self-sufficient that I am in no need of having an associate. Thus he who does an action for someone else’s sake as well as Mine will have that action renounced by Me to him whom he associated with Me.’” (Narrated by Muslim, al-Zuhd wa’l-Raqaiq, 5300)
The second condition is that the action should be in accordance with the only way which Allah has prescribed for worship, which is by following the Prophet (peace and blessings of Allah be upon him) in the laws that he has brought. It was narrated that the Prophet (peace and blessings of Allah be upon him) said: “Whoever does any action that is not in accordance with this matter of ours (i.e., Islam), will have it rejected.” (Narrated by Muslim, al-Aqdiyyah, 3243).
Ibn Rajab (may Allah have mercy on him) said: “This hadeeth (narration) forms one of the most important principles of Islam. It is like a scale for weighing up deeds according to their outward appearance, just as the hadeeth ‘The reward of deeds depends upon the intentions’ is the means of weighing up the inner nature of deeds. Just as every action which is not intended for the sake of Allah brings no reward to the one who does it, so too every deed which is not in accordance with the command of Allah and His Messenger will also be rejected and thrown back at the one who does it. Everyone who innovates in Islam something for which Allah and His Messenger have not granted permission, that thing has nothing to do with Islam.
(Jami’ al-‘Uloom wa’l-Hikam, part 1, p.176)
The Prophet (peace and blessings of Allah be upon him) enjoined following his Sunnah (ways) and teachings, and made them binding. He (peace and blessings of Allah be upon him) said: “You have to follow my Sunnah (way) and the way of my rightly-guided successors (al-khulafa’ al-rashidoon); bite onto it with your eyeteeth (i.e., cling firmly to it).” And he warned against bid’ah (innovation), as he said: “Beware of newly-invented matters, for every newly-invented matter is a going astray.” (narrated by al-Tirmidhi, al-‘Ilm, 2600; classed as saheeh/authentic by al-Albani in Saheeh Sunan al-Tirmidhi, no. 2157)
Ibn al-Qayyim said: “Allah has made devotion of worship to Him alone and following the Sunnah the means of deeds being accepted; if these conditions are not met, then deeds are unacceptable.”
Allah says (interpretation of the meaning):
“Who has created death and life that He may test you which of you is best in deed.”
Al-Fudayl said: “’best in deed’ means, most devoted to Allah alone and most in accordance with the Sunnah.
And Allah is the Source of strength.