"For the eyes of the Lord are over the righteous, and His ears are open unto their prayers: but the face of the Lord is against them that do evil" (I Peter 3:12).
There are many wonderful promises of answered prayer in the Bible, some of which seem both unlimited and unconditional. On the other hand, there are also many warnings of unanswered prayer. This seeming anomaly merely cautions us again that every Scripture must be interpreted in context -- both the immediate context and the broader context of all the Scriptures.
For example, Jesus said: "If ye shall ask any thing in my name, I will do it." But in the same upper-room discourse, He also said: "If ye abide in me, and my words abide in you, ye shall ask what ye will, and it shall be done unto you" (John 14:14; 15:7). This is a very significant condition, attached to what -- out of context -- might have seemed an unconditional promise.
Our text indicates that overt sin in one's life will certainly hinder God in answering our prayers. So will selfish praying: "Ye ask, and receive not, because ye ask amiss, that ye may consume it upon your lusts" (James 4:3). And so will unbelief: "When ye pray, believe that ye receive them, and ye shall have them" (Mark 11:24). Poor home relations also could be a factor. "Husbands...|give| honor unto the wife...that your prayers be not hindered" (I Peter 3:7).
Even when we are confident that we are fully right with God, the desired answer must still be in His will. "If we ask any thing according to His will...we have the petitions that we desired of Him" (I John 5:14-15).
Finally, there is the question of timing. "Men ought always to pray, and not to faint" (Luke 18:1). Therefore, the believing prayer of a man righteous before God surely will be answered in God's time and way. HMM