Is it permissible for a person to say in his du’aa’: O Allah, if I am sincere in this action of mine then make me succeed, or help me to complete this matter? In other words, connecting the answer to this supplication to sincerity in action; if Allah answers the prayer and makes the specific action complete, then this is a sign that Allah has accepted it and that he was sincere in it, but if Allah does not answer, then this is a sign that the person was not sincere, because he has made a connection between sincerity in his supplication and the action being done or completed.
It is permissible for a person to say in his supplication: O Allah, if I am sincere in this action of mine then make me succeed, or make it perfect for me.
Something like that is narrated in the hadeeth of the three people who were shut in the cave, and they asked Allah for help by virtue of their righteous deeds, and each of them said in his du’aa’: O Allah, if You know that I did that seeking Your Countenance, then grant us relief. And Allah answered their prayer. We will quote the text of this hadeeth here:
It was narrated that ‘Abd-Allaah ibn ‘Umar said: The Messenger of Allaah (blessings and peace of Allah be upon him)) said: “Whilst three men were walking, it began to rain, and they found shelter in a cave in a mountain. Then a rock from the mountain fell over the mouth of the cave, and they were trapped. They said to one another: See if you have done any righteous deeds for the sake of Allaah, and pray to Allaah by virtue thereof, so that He might remove the rock for you.
One of them said: O Allaah, I had my parents who were old, and my wife, and I had young children. I used to graze the sheep for them and when I come back in the evening, I used to milk (the sheep) and I would start with my parents, and give them to drink before my children. One day I was delayed and I did not come back until evening, and I found that they had gone to sleep. I milked (the sheep) as usual, then I brought the milk and stood by their heads, but I did not like to wake them from their sleep, and I did not like to give milk to the children before them. The children were crying at my feet, and I remained like that and they remained like that until dawn came. If You know that I did that seeking thereby Your Countenance, then open it a little for us, so that we may see the sky. Then Allaah opened it a little for them, and they could see the sky.
The next one said: O Allaah, I had a female cousin whom I loved as deeply as any man loves a woman, and I wanted to have my way with her, but she refused unless I brought her one hundred dinars. I worked hard and collected one hundred dinars, and brought that to her. But when I was between her legs, she said: O slave of Allaah, fear Allaah and do not break the seal except in a lawful manner. So I got up and left her. If You know that I did that seeking thereby Your Countenance, then open it some more for us. And He opened it some more for them.
The last one said: O Allaah, I hired a man in return for a measure (faraq) of rice, and when he had finished his work he said: Give me my wages. I offered the measure of rice to him but he refused it. So I sowed the rice many times until I had acquired cows and a herdsman thereby. Then he came to me and said: Fear Allaah and do not wrong me with regard to my wages. I said: Go to these cows and their herdsman and take them. He said: Fear Allaah and do not make fun of me. I said: I am not making fun of you. Take the cows and herdsman. So he took them and went away. If You know that I did that seeking thereby Your Countenance, then open the rest of it for us. So Allaah opened the rest of it.”
Narrated by al-Bukhaari (2272) and Muslim (2734).
But the fact that Allah helped him does not necessarily mean that this person was sincere in this action of his and if he is not helped it does not necessarily mean that he was not sincere.
Because he may have been sincere in his action, but Allah withheld the response for another reason, such as punishing him for sins that he committed or for consuming something haraam and so on.
And he may not have been sincere in his action but Allah completed it for him for a reason other than his supplication, either to let him get carried away or because this supplication happened to be in accordance with something that had already been decreed, so what Allah willed happened, but it was not because of the supplication.
And that may be an indication of his sincerity in action and that Allah accepted his supplication, but we cannot be certain of that.
And Allah knows best.