If the marriage contract to which you refer met the conditions of proposal and acceptance, and the presence of the woman’s wali (guardian) and two witnesses, and was done with the woman’s consent, then this is a valid marriage contract with all that that entails. The woman became his wife thereby and it is permissible for her husband to be intimate with her, including intercourse. But if he refrained from intercourse that would have been better, in accordance with custom and so as to avoid the negative consequences that result from that, such as suspicion and so on, especially since the marriage was not registered officially.
The child who results from this marriage is legitimate and is to be named after his father, because it is a valid marriage. See also question no. 75026.
But if the marriage did not fulfil the conditions, such as if there was no wali, then it is an invalid marriage according to the majority of fuqaha’, but the child should still be attributed to his father.
The one who did this marriage contract although he knew that it was haraam, and had intercourse after that, is a zaani (fornicator, adulterer) and is judged to be a faasiq (rebellious evildoer) unless he repents and become righteous.
Shaykh al-Islam Ibn Taymiyah said in al-Fataawa al-Kubra (3/326): Whoever has intercourse with a woman in an invalid marriage believing that she is his wife, his child from her is to be attributed to him, according to the consensus of the Muslims. End quote.
With regard to praying behind him, such prayers are valid, and what has happened does not undermine his religious commitment and he is not judged to be a faasiq (rebellious evildoer) because of it, because if the first marriage contract was valid, there is no problem and that does not undermine his religious commitment. But if it was invalid – such as if it was done without a wali – and it seems that he did that believing it to be permissible, then he is not sinning and he is not judged to be a faasiq because of that.
But this imam made a mistake by hastening to consummate the marriage before announcing the marriage and registering it officially, because that opens the door to gossip about him and his wife, and exposes him to talk. The one who is in a position where he is an example for people –such as an imam, teacher, mufti, qaadi and so on – should keep away from everything that may impugn their dignity and open the door to doubt and suspicion about them.
May Allaah help us all to do that which He loves and which pleases Him.
And Allaah knows best.