Sayyidina Umar ibn Khattab reported that Allah’s Messenger said, ‘Deeds revolve round the intention behind them. And (reward) for a man is what he intends. [hu,if a mans migration is for Allah and His Messenger then his migration is (recorded) for them; but, if his migration is for the world to earn it or for a woman to marry her then his migration is focussed on that for which he has migrated.”
[Bukhari 1,54, Muslim 1907]