With regards to the student of knowledge seeking and teaching knowledge purely for the sake of Allaah, Shaykh Saalih al Fawzaan hafidhahullaah comments on the hadeeth:
“And a man who gained knowledge and he taught it, and he recited Qur-aan; so he will be brought in order to inform him of His blessings so he will acknowledge them;
So He will say: What did you do with regards to them?
He will say, “I learned knowledge for Your sake and I taught it; and I recited the Qur-aan for Your sake.”
So He will say: You have lied! Rather you learned it so that it would be said “He is a person of knowledge” and this has already been said.
And you recited Qur-aan so that it would be said, “He is a person of recitation.” And this has already been said.”
Then he will be ordered to be dragged upon his face until he is thrown into the Fire.”
And this is from that which makes it binding upon the student of knowledge to purify his intention for Allaah, the Mighty and Majestic, in seeking knowledge.
So his goal should not be seeking to be raised up or a worldly position of responsibility or attaining the fleeting attractions of this worldly life through his knowledge and his teaching it.
Rather his intent is only for Allaah, the Mighty and Majestic because gaining knowledge and teaching it is from the noblest of righteous deeds ; so he does not divert it (away from its correct intention) and intend the dunyaa by means of it.
Rather he only wishes the Face of Allaah by it; and whatever wealth he is given – if he is given (it) – then it is something which (just happens) to follow on and it was not something he intended.
((Al minhat ul rabbaaniyah page 21 of Shaykh Saalih al Fawzaan hafidhahullaah, translated by Nasser ibn Najam)
 Reported by at Tirmidhee (2382) and Ahmad in his Musnad (2/321)