The Prophet ﷺ said, "Whoever seeks knowledge for other than Allah, or intends by it other than Allah, let him take his seat in the Fire."
حدثنا زيد بن أخزم وأبو بدر عباد بن الوليد قالا حدثنا محمد بن عباد الهنائي حدثنا علي بن المبارك الهنائي عن أيوب السختياني عن خالد بن دريك
أن النبي ﷺ قال من طلب العلم لغير الله أو أراد به غير الله فليتبوأ مقعده من النار
[Its isnad is daif] Tirmidhi transmitted it in the Book of Knowledge, chapter on one who seeks worldly gain through his knowledge, hadith no. 2655, from the hadith of Muhammad bin Abbad, with this wording, and he said, hasan gharib. Khalid bin Durayk did not meet Ibn Umar.