Alqamah bin Waqqas said: I heard Sayyiduna Umar (may Allah be pleased with him) saying that the Messenger of Allah (peace and blessings be upon him) said: "Actions depend on intention, and a person will get only what he intended. So whoever's emigration is for Allah and His Messenger will be rewarded accordingly, and whoever's emigration is for some worldly gain that he wants to obtain, or for a woman whom he wants to marry, his emigration will be counted for that for which he emigrated."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 2254