The prerequisites for deeds to be accepted

What are the prerequisites for deeds to be accepted?

There are two conditions for deeds which draws a person closer to Allaah to be accepted:
Firstly: sincerity to Allaah, Most High and Exalted. Allaah says in the Qur’an, 

وَمَآ أُمِرُوٓاْ إِلَّا لِيَعۡبُدُواْ ٱللَّهَ مُخۡلِصِينَ
And they were not commanded except to worship Allaah, [being] sincere to Him (Al-Bayyinah, 5)

And due to the Hadith of ‘Umar narrated by Al-Bukhaary and Muslim, ‘Indeed all actions depend upon intention. And every person shall be rewarded with what he intended’ (Al-Bukhaary, 1). Therefore, any deeds which are not meant to please Allaah are rejected. 
Secondly, the Messenger of Allaah ﷺ saying many times ‘Whoever does anything which is not according to our instructions then it is rejected’ [Muslim, 1718]. Likewise, it is recorded in an authentic Hadith on the authority of ‘Aaisha (may Alllaah pleased with her) ‘Whoever does something which is not from our instructions then that is rejected’ [Al-Bukhaary, 2697]. The meaning of ‘rejected’ is that it is returned to him. Hence, deeds which were not meant sincerely for Allaah, Most Exalted, are not accepted. It is also not accepted if it was not done in the way instructed by the Prophet ﷺ.

The verse,  
لِيَبۡلُوَكُمۡ أَيُّكُمۡ أَحۡسَنُ عَمَلٗاۚ
[He] who created death and life to test you [as to] which of you is best in deed (Al-Mulk, 2)

 Regarding this verse, Al-Fudayl ibn ‘Iyad said: ‘The most sincere and the most correct’. It was said, ‘O Abu ‘Ali what is most sincere and most correct?’ He said, ‘If deeds are not sincerely done for Allaah it is not accepted’. Likewise, if it is not according to the guidance of the Prophet ﷺ it is not accepted. Therefore, it behoves that the intention of a Muslim should always be sincere and righteous, and he should also always continue to refine it. This is because it is easy for intention to become muddled. So, a person can have the right intention to do a good deed, but it is possible for him to become unaware of the right intention and therefore defects and deficiencies can take place in  the intention whereby the deeds are affected. 

Likewise, it is obligatory for a Muslim to make sure his deeds are such that they will draw him closer to Allah, Most Exalted, and in accordance with the teachings of the Prophet ﷺ in order to safeguard himself from committing innovation. This is realising the oneness of Allaah, Most High, meaning being sincere to Him and ridding his actions of doubts, and ascribing in partnership with Allaah, innovations, major and minor sins. Also, disobedience must be avoided, this is because disobedience is an obstacle to deeds being accepted by Allaah or that the deed will become compensation for shortcomings in other deeds as it is stipulated in the Hadith recorded about the one who is ‘bankrupt’. 
Hence, it is a duty for a person who is doing a good deed to ensure the aforementioned two conditions are observed. This is because some people are eager to do good deeds, which is something good and encouraged by the legislation, but they are not able to separate their good actions from bad. In most cases, such a person who is given reward is not the person most beloved to Allaah. Like it is mentioned in the Hadith about the ‘bankrupt’ person. The Prophet ﷺ once asked his Companions who is bankrupt? They replied, a bankrupt person is he who has no money or belongings. The Prophet ﷺ said, ‘The bankrupt from my followers is he who will come on the Day of Judgement with deeds of prayers, fasting, zakat. However, he insulted so and so, he slandered so and so, he stole the property of so and so, he killed so and so, he assaulted so and so. Now those victims will be compensated with his good deeds and once his good deeds have finished before all the claims have been settled against him, he will start to take on the sins of his victims, they will be given to him and then he will be cast into Hell’ [Muslims, 2581]. Therefore, a person must do good deeds and he must observe sincerity and following the Prophet ﷺ. After that he should protect his good deeds so they remain for him on his register of good deeds for the Day of Judgement. 
There are some students of Islamic studies studying at institutions and universities, and they seek to study to acquire knowledge and there is nothing but reward for that. However, it can be noted that at the same time the student seeks to attain a certificate, and the reason behind attaining this certificate is to give him access to a job and earning money. The question is what is the quality of his intention in seeking knowledge?
Students of Islamic studies asked this question quite a lot. They say, we have worked really hard, and we have not chosen this faculty accept to seek knowledge. However, we have noticed that it is in order to graduate and get a certificate as well as what follows from gaining a university education. What many people think is this is security for the future this is something that we cannot overcome, nor can we break. So, is the solution to leave studying at this faculty?
To this we say, no this isn't the solution. rather the solution is to fight and strive with yourself to rectify your intention. Therefore, students must try to strive to correct his intention. He should know that Allah, Most High, will help him if he he's truthful in trying to correct his intention. It has been recorded from some of the pious predecessors that they sought knowledge for a reason other than pleasing Allaah. They rejected it and strove to make it only for Allaah. It is not befitting for a student to take this lightly and say, ‘I am a student of knowledge for the sake of a certificate as well as a job’ and then he should fix his intention. Rather, he needs to strive with himself to fix his intention from the beginning. Once his intention is true then Allaah most high will help him but leaving studying Islamic studies is not the solution.