It is reported by ‘Umar ibn Al Khattab (May Allah be pleased with Him) that he said:
I heard the Apostle of Allaah(ﷺ) saying:
“Actions are to be judged only by intentions and a man will have only what he intended. When one’s emigration is to Allaah and His Apostle, his emigration is to Allaah and His Apostle but whose emigration is to a worldly end at which he aims or to a woman whom he marries, his emigration is to that for which he emigrated.”
[Reported by Abu Dawood, Al-Bukhari and Muslim]
Great article, very useful !!