Conditions of righteous deeds
Question

When does Allah accept a person’s deeds? What are the conditions for a deed to be righteous and acceptable to Allah?
Praise be to Allah.An action cannot be an act of worship unless it includes two things: complete love and complete humility. Allah says (interpretation of the meaning): 
“But those who believe, love Allah more (than anything else)” [al-Baqarah 2:165] 
“Verily, those who live in awe for fear of their Lord” [al-Mu’minoon 23:57]
And Allah mentions them together in the aayah (interpretation of the meaning): 
“Verily, they used to hasten on to do good deeds, and they used to call on Us with hope and fear, and used to humble themselves before Us” [al-Anbiya’ 21:90]
Once this is understood, we will realize that worship can only be accepted from a Muslim who believes in Allah alone (Tawheed), as Allah says (interpretation of the meaning): 
“And We shall turn to whatever deeds they (disbelievers, polytheists, sinners) did, and We shall make such deeds as scattered floating particles of dust” [al-Furqaan 25:23]
In Saheeh Muslim (214) it is narrated that ‘Aa’ishah (may Allah be pleased with her) said: “I said, ‘O Messenger of Allah, during the Jaahiliyyah, Ibn Jud’aan used to uphold the ties of kinship and feed the poor. Will that avail him anything?’ He said, ‘It will not avail him anything because he never said, “O Allah, forgive me my sins on the Day of Judgement”’” – i.e., he did not believe in the resurrection or do good deeds hoping to meet Allah. 
Moreover, the Muslim’s worship will not be accepted unless it meets two basic conditions: 
1 – Sincerity of intention towards Allah, which means that the person’s intention in all his words and deeds, both outward and inward, is to seek the pleasure of Allah and none other. 
2 – It should be in accordance with the sharee’ah which Allah has prescribed, and he should not worship Allah in any other way. That is achieved by following the Prophet (peace and blessings of Allah be upon him) and what he brought, and shunning anything that goes against it, and not inventing any new form of worship that has not been narrated in sound reports from the Prophet (peace and blessings of Allah be upon him). 
The evidence for these two conditions is the aayah (interpretation of the meaning): 
“So whoever hopes for the Meeting with his Lord, let him work righteousness and associate none as a partner in the worship of his Lord” [al-Kahf 18:110]
Ibn Katheer (may Allah have mercy on him) said: “ ‘So whoever hopes for the Meeting with his Lord’ means his reward; ‘let him work righteousness’ means, that which is in accordance with the laws of Allah; ‘and associate none as a partner in the worship of his Lord’ this means seeking the Face of Allah alone, with no partner or associate. These two conditions are the basis of acceptable deeds, which must be sincerely for the sake of Allah alone and correct according to the sharee’ah of the Messenger of Allah (peace and blessings of Allah be upon him).