The Messenger of Allah ﷺ said, "Whoever Allah wishes good for, He grants him understanding of the religion."
حدثنا بكر بن خلف أبو بشر حدثنا عبد الأعلى عن معمر عن الزهري عن سعيد بن المسيب
قال رسول الله ﷺ من يرد الله به خيرا يفقهه في الدين
[Sahih] Tabarani narrated it in Al-Saghir, no. 810, from the hadith of Mamar through this route, and Ahmad narrated it (2/234) from Abdul-Ala through this route. Zuhri narrated with an ambiguous form indicating a possible gap in the chain, but it has many corroborating narrations in Bukhari, no. 71, and Muslim, no. 1037, and others.