TIRMIDHI 1647: from Muḥammad b. al-Muthanná —
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.

الترمذي ١٦٤٧: عن محمد بن المثنى —
قَالَ رَسُولُ اللَّهِ ﷺ إِنَّمَا الأَعْمَالُ بِالنِّيَّةِ وَإِنَّمَا لاِمْرِئٍ مَا نَوَى فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللَّهِ وَإِلَى رَسُولِهِ فَهِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ وَمَنْ كَانَتْ هِجْرَتُهُ إِلَى دُنْيَا يُصِيبُهَا أَوِ امْرَأَةٍ يَتَزَوَّجُهَا فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ


Sound (ʿAli Zaʾī)
Tirmidhī > Virtues of Jihād > § What Has Been Related About One Who Fights For Show And...
hadithunlocked.com