Narrated 'Umar bin Al-Khattab:
That the Messenger of Allah (ﷺ) said: Deeds are but with intentions, and for the man is only what he intended. So one whose emigration was to Allah and His Messenger, then his emigration was to Allah and His Messenger. And one whose emigration was to the world, to attain some of it, or woman, to marry her, then his emigration was to what he emigrated.
[Abu 'Eisa said:] This Hadith is Hasan Sahih. Malik bin Anas, Sufyan Ath-Thawri and more than one of the A'immah narrated this Hadith from Yahya bin Sa'eed. And we do not know of it except as a narration from Yahya bin Sa'eed Al-Ansari. 'Abdur Rahman bin Mahdi said: It is necessary that we put this Hadith in every chapter.