Umar bin Khattab reported,

The Messenger of Allah ﷺ said, "Actions are judged only by intentions, and each person will have only what they intended. Whoever migrates for the sake of Allah and His Messenger, his migration is for Allah and His Messenger. And whoever migrates for some worldly gain to be acquired or a woman to be married, his migration is for whatever he migrated toward."

Tirmidhi 1647

Sahih

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

عن عمر بن الخطاب قال

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

الترمذي 1647صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Virtues of jihad
Chapter
One who fights for showing off and worldly gain
Numbering
Darussalam 1647
Tirmidhi 1647