Viewing 1 replies (of 1 total)
  • Thread Starter stromdh

    (@stromdh)

    nobody know nothing in this forum… if anyone needs, here it is:

    `add_action( ‘wpcf7_before_send_mail’, ‘cria_xml_cf7’ );

    function cria_xml_cf7( $cf7 )
    {
    function addContato($document, $nome, $email, $assunto, $mensagem)
    {
    #criar contato
    $contato = $document->createElement(“contato-body”);
    #criar nó nome
    $nomeElement = $document->createElement(“nome”, $nome);
    $emailElement = $document->createElement(“email”, $email);
    $telefoneElement = $document->createElement(“assunto”, $assunto);
    $mensagemElement = $document->createElement(“msg”, $mensagem);
    $contato->appendChild($nomeElement);
    $contato->appendChild($emailElement);
    $contato->appendChild($telefoneElement);
    $contato->appendChild($mensagemElement);
    return $contato;
    }
    $dom = new DOMDocument(“1.0”, “ISO-8859-1”);
    $dom->preserveWhiteSpace = false;
    $dom->formatOutput = true;
    $root = $dom->createElement(“item”);
    #utilizando a funcao para criar contatos
    $cf7Nome = $_POST[“nome”];
    $cf7Email = $_POST[“email”];
    $cf7Assunto = $_POST[“assunto”];
    $cf7Msg = $_POST[“msg”];
    $item = addContato($dom, $cf7Nome, $cf7Email, $cf7Assunto, $cf7Msg);
    #adicionando no root
    $root->appendChild($item);
    $dom->appendChild($root);
    #salvando o arquivo
    $dom->save(date(‘d-m-Y’).”nome.xml”);
    #mostrar dados na tela
    header(“Content-Type: text/xml”);
    $dom->saveXML();
    }

Viewing 1 replies (of 1 total)

The topic ‘how send xml file’ is closed to new replies.