Umar bin Khattab reported,

The Prophet ﷺ said, "Deeds are judged by intentions, and each person receives only what he intended. Whoever's migration was for Allah and His Messenger, his migration is to Allah and His Messenger ﷺ. And whoever's migration was for some worldly gain he sought or a woman he wished to marry, his migration is to whatever he migrated for."

Bukhari 5070

Sahih

حدثنا يحيى بن قزعة حدثنا مالك عن يحيى بن سعيد عن محمد بن إبراهيم بن الحارث عن علقمة بن وقاص

عن عمر بن الخطاب رضي الله عنه قال

قال النبي ﷺ العمل بالنية وإنما لامرئ ما نوى فمن كانت هجرته إلى الله ورسوله فهجرته إلى الله ورسوله ﷺ ومن كانت هجرته إلى دنيا يصيبها أو امرأة ينكحها فهجرته إلى ما هاجر إليه

البخاري 5070صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Marriage
Chapter
One who emigrated or did good deeds to marry a woman will have what he intended
Numbering
Darussalam 5070
Bukhari 5070