He did the marriage contract unofficially with his wife because of delays in government procedures
Question

                I have legally divorced my wife and she finished her ‘iddah. I wanted to marry another woman but in the Moroccan law a man cannot marry until he gets a permission of divorce from the court, which can be delayed due to governmental procedures. It was too difficult for me to wait two more months while I divorced my wife four months ago. I found it really difficult to wait; I found myself between two options, whether to fall into zina (adultery) and this is case of most husbands, or to be patient while it is too difficult. You know how the Moroccan streets are now, full of nudity and immorality. My fiancée’s wali (guardian) has given me permission to marry her. I gave the dowry and two witnesses attended while a just clerk wrote an informal contract to keep until I get the permission of divorce from the court. We had the contract concluded in such a way thinking that all the Islamic conditions of marriage contract are fulfilled. We cannot announce this marriage except after two months. But a brother told me recently that what we did is Islamically illegal. Please tell me your opinion may Allah reward you!.
Praise be to Allah.
    If the marriage contract to which you refer fulfilled all the 
    necessary conditions and included the proposal and acceptance, in the 
    presence of the woman’s wali (guardian) and two witnesses, with the woman’s 
    consent, then it is a valid marriage with all that that entails, and the 
    woman has become your wife thereby, even if it has not been announced and 
    publicized and even if it has not been recorded officially, because the 
    Prophet  (peace and blessings of Allaah be upon him) said: “There is no 
    marriage except with a wali (guardian).”  Narrate by Abu Dawood (2085), 
    al-Tirmidhi (1101) and Ibn Majaah (1881) from Abu Moosa al-Ash’ari; classed 
    as saheeh by al-Albaani in Saheeh al-Tirmidhi. 

    And he  (peace and blessings of Allaah be upon him) said: 
    “There is no marriage except with a guardian and two witnesses of good 
    character.” Narrated by al-Bayhaqi from ‘Imraan and ‘Aa’ishah; classed as 
    saheeh by al-Albaani in Saheeh al-Jaami’ (7557). 

    Having the marriage documented in the court and so on is not 
    a condition of the marriage being valid, rather it is done to protect 
    people’s rights, and hence it is essential. But it does not matter if that 
    is delayed until you obtain the divorce documents.  

     We ask Allaah to bless you and to bring you both together in 
    goodness. We advise you to fear Allaah and treat your wife kindly, and to 
    establish a righteous Muslim household. 

    And Allaah knows best.