Sulayman bin Mansur reported,

Abdullah bin Mubarak informed us, and the wording is his, from Yahya bin Saeed, from Muhammad bin Ibrahim, from Alqama bin Waqqas, from Umar bin Khattab رضي الله عنه, who said that the Messenger of Allah ﷺ said, "Actions are judged only by intentions, and every person will receive only what they intended. Whoever's migration was for Allah and His Messenger, their migration was for Allah and His Messenger. And whoever's migration was for some worldly gain to be obtained or a woman to marry, their migration was for whatever they migrated to."

Nasai 75

Sahih

أخبرنا يحيى بن حبيب بن عربي عن حماد والحارث بن مسكين قراءة عليه وأنا أسمع عن ابن القاسم حدثني مالك ح و أخبرنا

سليمان بن منصور قال

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

النسائي 75صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Purification
Chapter
Intention in wudu
Numbering
Darussalam 75
Nasai 75