I need to integrate a SOAP service with the WordPress plugin Contact Form 7.
In a simple HTML form, I've obtained this result passing via Ajax the form datas to an external PHP file. Here's the code:
HTML
<form id="newsletterForm" action="">
<input id="emailField" type="email" name="email" placeholder="La tua email" data-validation="email" />
<input id="submitButton" type="submit" onclick="submitNewsletter();">
</form>
JS
function submitNewsletter(){
data=$('#newsletterForm').serialize();
$.ajax({
url: "soap.php",
type:'POST',
data:data,
async:false,
dataType:'html',
});
}
SOAP.PHP
<?
$email= $_POST["email"];
$client = new
SoapClient("http://sms.dmmplatform.net/api/webservice/?wsdl");
$details[0]['email'] = "$email";
$details[0]['groups']="MYGROUP";
$json_details = json_encode($details);
$risposta = $client->addContactV2("myUsername", "myPassword", $json_details);
?>
Now I need to obtain the some result using WordPress and CF7. This is my first time with this plugin. After reading the documentation, I've tried to use the wpcf7submit event but nothing happens:
add_action( 'wp_footer', 'CF7ajaxSendToADA' );
function CF7ajaxSendToADA(){
?>
<script>
document.addEventListener( 'wpcf7submit', function( event ) {
if ( '381' == event.detail.contactFormId ) {
data=$('#newsletterForm').serialize();
$.ajax({
url: "soap.php",
type:'POST',
data:data,
async:false,
dataType:'html',
});
}
}, false );
</script>
<?php
}
Any idea?
Thank you very much for your help!!