The Prophet (peace and blessings of Allaah be upon him) said that the one who eats or wears haraam things will receive no answer (to his du’aa’). Is the du’aa’ of the sinner not answered?.
Answer to the du’aa’ of one who calls upon Allaah is, in principle, an indication of the righteousness and piety of that person, but it does not always indicate that. A sinner’s du’aa’ may be answered as a means of letting him get carried away or for a reason. Allaah answered the prayer of the Shaytaan when he said:
“ ‘O my Lord! Give me then respite till the Day they (the dead) will be resurrected.’
37. Allaah said: ‘Then verily, you are of those reprieved’”
This response was not an honour for him, rather it was a humiliation, to increase his sin so that his punishment would be greater – we seek refuge with Allaah.
And it is proven that the Prophet (peace and blessings of Allaah be upon him) said: “The prayer of the one who is oppressed is answered even if he is an evildoer, and his evildoing is upon himself.” Narrated by Ahmad. See Saheeh al-Jaami’, 3382.
Similarly, the fact that a du’aa’ is not answered does not always mean that the one who is praying is corrupt. There are some prayers which Allaah did not grant our Prophet Muhammad (peace and blessings of Allaah be upon him). He (peace and blessings of Allaah be upon him) said: “I asked my Lord for three things, of which He granted me two…” Narrated by Muslim, 2890.
Allaah did not answer some of the prayers of His Prophet (peace and blessings of Allaah be upon him) for an important reason, which was to teach mankind that he had no control over anything, rather everything was under the control of Allaah.
See Sharh al-Arba’een li’l-‘Allaamah al-Nawawi, and Kitaab al-Du’aa’ by Shaykh Muhammad al-Hamad.