Umar bin Khattab reported,

The Messenger of Allah ﷺ said, "Actions are judged only by intentions, and every person will have only what they intended. So whoever migrated for the sake of Allah and His Messenger, his migration is for Allah and His Messenger. And whoever migrated for some worldly gain he sought, or a woman he wished to marry, his migration is for whatever he migrated toward."

Azami 1

Sahih

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

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

الأعظمي 1صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Revelation
Section
Actions are judged by intentions
Numbering
Jami al-Kamil 1 (2nd edition)
Azami 1