Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:39:49

And when adversity touches man, he calls upon Us; then when We bestow on him a favor from Us, he says, "I have only been given it because of ˹my˺ knowledge." Rather, it is a trial, but most of them do not know.  

So when some distress befalls man (al-insān, here a generic), he supplicates Us. Then, when We bestow on him a grace from Us, he says, ‘I was given it merely by force of knowledge’, from God that I was deserving of it. Nay, but it, this saying, is a trial, a test by which servants are tested. But most of them do not know, that such bestowal ˹of grace˺ is a way of drawing ˹them˺ on and a test ˹of their faith˺.
القرآن:٣٩:٤٩

فَإِذَا مَسَّ الْإِنْسَانَ ضُرٌّ دَعَانَا ثُمَّ إِذَا خَوَّلْنَاهُ نِعْمَةً مِنَّا قَالَ إِنَّمَا أُوتِيتُهُ عَلَىٰ عِلْمٍ ۚ بَلْ هِيَ فِتْنَةٌ وَلَٰكِنَّ أَكْثَرَهُمْ لَا يَعْلَمُونَ  

{فإذا مسَّ الإنسان} الجنس {ضر دعانا ثم إذا خوّلناه} أعطيناه {نعمة} إنعاما {منا قال إنما أوتيته على علم} من الله بأني له أهل {بل هي} أي القولة {فتنة} بلية يبتلى بها العبد {ولكن أكثرهم لا يعلمون} أي التخويل استدراج وامتحان.