Actions are by intentions
It is narrated on the authority of Amir al-Mu'minin (Leader of the Believers), Abu Hafs 'Umar bin al-Khattab (may Allah be pleased with him), who said: I heard the Messenger of Allah (peace be upon him), say
"Actions are according to intentions, and everyone will get what was intended. Whoever migrates with an intention for Allah and His messenger, the migration will be for the sake of Allah and his Messenger. And whoever migrates for worldly gain or to marry a woman, then his migration will be for the sake of whatever he migrated for."
Related by Bukhari & Muslim
عَنْ أَمِيرِ الْمُؤْمِنِينَ أَبِي حَفْصٍ عُمَرَ بْنِ الْخَطَّابِ رَضِيَ اللهُ عَنْهُ قَالَ:
سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ: " إنَّمَا الْأَعْمَالُ بِالنِّيَّاتِ، وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إلَى اللَّهِ وَرَسُولِهِ فَهِجْرَتُهُ إلَى اللَّهِ وَرَسُولِهِ، وَمَنْ كَانَتْ هِجْرَتُهُ لِدُنْيَا يُصِيبُهَا أَوْ امْرَأَةٍ يَنْكِحُهَا فَهِجْرَتُهُ إلَى مَا هَاجَرَ إلَيْهِ".
رَوَاهُ إِمَامَا الْمُحَدِّثِينَ أَبُو عَبْدِ اللهِ مُحَمَّدُ بنُ إِسْمَاعِيل بن إِبْرَاهِيم بن الْمُغِيرَة بن بَرْدِزبَه الْبُخَارِيُّ الْجُعْفِيُّ [رقم:1]، وَأَبُو الْحُسَيْنِ مُسْلِمٌ بنُ الْحَجَّاج بن مُسْلِم الْقُشَيْرِيُّ النَّيْسَابُورِيُّ [رقم:1907] رَضِيَ اللهُ عَنْهُمَا فِي "صَحِيحَيْهِمَا" اللذَينِ هُمَا أَصَحُّ الْكُتُبِ الْمُصَنَّفَةِ.
This hadith is central to Islamic thought, culture, and understanding and shows the balance between the internal and external states of oneself. This hadith is great in its benefit and importance, and it has been said that Islam revolves around it. Scholars have commented that this hadith comprises one-third of knowledge because the actions of man involve his heart, his tongue and his limbs, and hence the intention in the heart is one-third of action. It is also deemed to be one-third of knowledge due to scholars commenting that this hadith along with two others comprises the religion of Islam. The other two hadith being “The Halal is clear and the Haram is clear and between them are doubtful matters”(1), and “Whoever innovates in this religion that which is not from it will have all his actions rejected (by Allah).”(2)
Actions are based on intention
The connection between action and intention highlights the connection between the physical and the spiritual components of any human. This hadith emphasizes on the importance of having an intention for every physical act that we do, and the importance of having a purpose for every action. It also brings to the forefront our conscious intention and the need to make the connection between our physical actions and their spiritual consequences.
Intentions lead to results. When a change in intention occurs, a change in the external conditions will follow. Intention is also enough for Allah (swt) to make a change in our reality, so we should not belittle the necessary change in intention that has to occur in order for our external condition to change.
Specifically in regards to Islamic work and worship, the quality of intention is very important. Involvement in Islamic work should not be primarily intended for marriage or fame, but to worship Allah, help our community and spread love amongst our community.
Being a visionary
The believers should be visionaries because they should always be checking their intentions and understanding the purpose of their actions. They should be persistently asking themselves about their intentions for their short term and their long goals. Overall, the believer should constantly ask himself; “Why am I doing what I am doing?”
Using the words “shall have" in this hadith means that the person will be rewarded for only that which he intended. So, as mentioned in the hadith, if a person performed the Hijrah, but did it with a different intention then he would not be rewarded for that action of Hijrah.
Riya?, the showing off of deeds publicly, is a major sin which ruins sincerity and can invalidate actions. In the wording of the hadith, the use of the word “by” in “actions are but by intention” refers to the fact that the acceptance and correctness of any action depends on the intention behind it. For example, giving money in charity will not be accepted as a good deed if it was for the sake of showing off to others.
The Prophet (sas) informed us that if you perform an act for the sake of someone else rather than for Allah’s sake, then Allah will reject that deed entirely and will leave the reward of it for the partner that the person has made. This highlights the implications of showing off as well as the graveness of associating another person in your actions which should have been for the sake of Allah (swt). As mentioned in the hadith, 'Thus he whose migration was for Allah and His messenger, his migration was for Allah and His messenger, and he whose migration was to achieve some worldly benefit or to take some woman in marriage, his migration was for that for which he migrated.”
Everything we do has to be intended for the sake of Allah (swt). A good action with the wrong intention will not get us any reward in the Hereafter.
 Hadith 5: Rejection of Evil Deeds and Innovations
 Hadith 6: The Halal is Clear and the Haram is Clear