This is an interesting quotation from Ibn Taymiyyah, describing the situation of Muslims whose Islam is hukmi (i.e., they’re simply Muslims by name). Outwardly, he’s performing his obligations, except that he doesn’t do so out of the desire for reward from Allah for performing them, or out of fear of His punishment for abandoning them. Rather, he does what he does simply to go along with what his parents, environment, etc., expect of him:
“…Most Muslims are born to two Muslim parents, essentially becoming Muslims by name, without there being any actual faith on their part. Then, when they reach puberty, from them are those that are blessed with actual faith, performing their obligations. Likewise, from them are those who perform these acts out of ingrained habit, and just to go along with his relatives, the people of the land in which he lives, etc. For example, he gives Zakah simply because it is a habitual tradition that the ruler collects tax, and not because he realizes either the generality or specifics of the obligation to pay it. So, in his eyes, there is no difference between the innovated tax and the legislated Zakah. Such is the case with the inhabitant of Makkah who goes out to ‘Arafat every year simply because this is the way it is done, without realizing the generality or specifics of this being an act of worship of Allah.
So, the acts of worship performed by such people is invalid, without a doubt. In fact, the texts of the Qur’an and Sunnah, as well as the consensus of the Ummah, are clear in the ruling that these actions do not fulfill the obligation placed upon their doer…
…So, the Islam of most people is by name, only. Rather, it (faith) only enters into their hearts during the course of the matter (i.e., later in their lives), if it enters at all. So, were this intention not to be obligatory upon them, they would not at all attempt to have it, and their hearts would be empty of it, and they would essentially be hypocrites, carrying out their actions out of habit and imitation, as is the case with many people.” [‘Majmu’ al-Fatawa’; 26/32]
Also, commenting on the hadith of the questioning in the grave: “…as for the hypocrite or disbeliever, it will be asked of him: ‘What did you say about this man?’ He will say: ‘I do not know! I used to say what I heard the people saying!’” Ibn Hajar al-’Asqalani said:
“And in it is the blameworthiness of believing in something in order to follow others, due to the punishment that will be meted out to the one who said: ‘I used to hear the people saying something, so, I said it.’” [‘Fath al-Bari’; 3/284]