The supplication of the Muslim is answered by granting him what he seeks or otherwise
Question

Will a person’s supplication asking to be enabled to adhere soundly to his religion definitely be answered in this world, if he is sincere in his supplication, such as if he asks Allah for certain faith? And will his supplication for well-being in the hereafter definitely be answered, if he is sincere in his supplication, such as if he asks Allah for al-Firdaws?
Praise be to Allah.What is required of the Muslim is to worship Allah, may He be glorified and exalted, by offering supplication (du‘aa’), being certain of a response, whilst thinking positively of Allah, may He be glorified and exalted, and taking measures to ensure that his supplication will be answered, then putting his trust in Allah, may He be glorified and exalted, and leaving the matter of the response to His mercy, kindness and wisdom, for Allah, may He be glorified and exalted, knows best what is appropriate for His slave in this world and will save him in the hereafter. What matters is that he should not despair, even if he must be patient and wait for a long time, and he should not be impatient and say: I offered supplication and did not receive a response. Du‘aa’ in and of itself is an act of worship that is only for Allah, and is to be done for its own sake, not only done for the purpose of getting a response.
It is proven from Abu Sa‘eed al-Khudri (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said:  There is no Muslim who offers a supplication in which there is no sin or severing of ties of kinship, but Allah will give him one of three things in return for it: either He will hasten for him what he asked for, or He will store it [the reward for it] up for him in the Hereafter, or He will avert from him an equivalent evil.” They said: Then we should do a lot of that [offering supplication]. He said “Then Allah will reward you more.”
Narrated by Ahmad in al-Musnad (17/213); classed as hasan by the commentators in the Mu’sasat ar-Risaalah edition. Its isnaad was classed as jayyid by al-Mundhiri in at-Targheeb wa’t-Tarheeb; and classed as saheeh by al-Albaani in Saheeh al-Adab al-Mufrad (547).
Imam an-Nawawi included it in a chapter in his book al-Adhkaar (p. 410) entitled: Chapter on the evidence that the supplication of the Muslim is answered by granting him what he seeks or otherwise.
The specific thing that is sought – whether it is for sound religious commitment, or for well-being in the hereafter or in this world – may not be achieved; rather Allah may grant him an alternative, in this world or in the hereafter, or He may avert from him an equivalent evil in this world.
Ibn ‘Abd al-Barr (may Allah have mercy on him) said commenting on the hadith quoted above:
This indicates that he will inevitably receive one of these three responses. Based on that, the words of Allah, may He be glorified and exalted (interpretation of the meaning), “and He would remove that for which you invoked Him if He willed” [al-An‘aam 6:41] would be interpreted – and Allah knows best – as meaning that He is going to will that, and no one could compel Him. And the verse (interpretation of the meaning), “I respond to the invocation of the supplicant when he calls upon Me” [al-Baqarah 2:186] is to be understood according to the apparent and general meaning, based on the understanding of the hadith of Abu Sa‘eed quoted above. Allah knows best what He meant in this verse, and what the Messenger of Allah (blessings and peace of Allah be upon him) meant.
Supplication (du‘aa’) is all goodness, worship and good deeds, and Allah does not cause to be lost the reward of one who does good. It was narrated from Abu Hurayrah that he used to say: I am not afraid of being deprived of the response; rather I am afraid of being deprived of offering supplication.
In my view, he understood the verse about the response to supplication (al-Baqarah 2:186) as being general in meaning, and as a promise, and Allah does not break His promise.
End quote from at-Tamheed lima fi’l-Muwatta’ min al-Ma‘aani wa’l-Asaaneed (10/297-299).
Ibn Hajar (may Allah have mercy on him) said:
Every supplicant receives a response, but the response varies. Sometimes he gets exactly what he prayed for, and sometimes he gets something else as compensation. This is mentioned in a saheeh hadith; it was narrated by at-Tirmidhi and al-Haakim from ‘Ubaadah ibn as-Saamit, in a marfoo‘ hadith [i.e., attributed to the Prophet (blessings and peace of Allah be upon him)]: “There is no Muslim on earth who offers supplication but Allah will grant it to him, or will avert an equivalent evil from him.” And it was narrated by Ahmad from Abu Hurayrah: “Either He will hasten it for him or He will store it [its reward] up for him.”
End quote from Fath al-Baari (11/95).
Shaykh Ibn Baaz (may Allah have mercy on him) said:
Persisting in supplication, thinking positively of Allah and not despairing are among the greatest means of receiving a response. So the individual should persist in offering supplication and think positively of Allah, may He be glorified and exalted, and he should know that He is all-wise, all-knowing; He may hasten the response for a reason, or He may delay it for a reason, or He may give the supplicant something better than what he asked for.
End quote from Majmoo‘ Fataawa Ibn Baaz (26/122).
Shaykh al-Barraak (may Allah preserve him) said:
Response to supplication is more general than meeting needs, so if the thing asked for is not granted, that does not mean that Allah did not respond to your supplication. So you should not say, Allah does not answer my prayers! How do you know? Perhaps Allah has given you one of these three responses. Because of that, I say that the phrase ‘meeting needs’ is more specific than the phrase ‘Allah, may He be exalted, answers supplications.’
End quote from Sharh al-‘Aqeedah at-Tahhaawiyyah (p. 348).
This means that you should offer supplication being certain of a response, whether you see it in this world or it is delayed until the hereafter. Allah, may He be glorified and exalted, will surely show His generosity to anyone who meets the conditions of supplication being answered.
On our website, there are many answers in which you may learn more about this topic. See questions no. 212629 and 135085.
And Allah knows best.