Awesome suggestions!
But may I ask further if the form data captured sends to espoCRM as a Ticket case immediately? is there a straight resolution?
Thanks in advance.
Wordpress Form Integration
Collapse
X
-
It is also possible, I recommend it works very well, it is to save the records in the database and keep it in the same database EspoCrm, I leave here the script that I created it with the wordpress plugin "Smart Forms"
<?php
/**
* Plugin Name: Smart Forms - Save To Database
*/
add_filter('sf_after_saving_form', 'smart_forms_store_in_database');
function smart_forms_store_in_database($entry)
{
if ($entry->FormId != 93)
{
return;
}
date_default_timezone_set('Europe/Madrid');
$crmid = $entry->GetFieldValue('rnField381');
$correocliente = $entry->GetFieldValue('rnField169');
$cif = $entry->GetFieldValue('rnField168');
$NombreCliente = $entry->GetFieldValue('rnField162');
$idoferta = $entry->GetFieldValue('rnField174');
$Administrador = $entry->GetFieldValue('rnField292');
$ideequipo = $entry->GetFieldValue('rnField386');
$iddb = $entry->GetFieldValue('rnField387');
$CorreoCliente = $entry->GetFieldValue('rnField379');
$hoy = date("Y-m-d H:i:s");
$a = "0";
$b = "0";
$c = "0";
$t = "Contact";
$idusuario = $entry->GetFieldValue('rnField382');
$paquete = $entry->GetFieldValue('rnField220');
/* $lineas = $entry->GetFieldValue('rnField221'); */
$usuario = $entry->GetFieldValue('rnField363');
$cliente = $entry->GetFieldValue('rnField379');
$lineasfibra = $entry->GetFieldValue('rnField475');
/* $lineasadsl = $entry->GetFieldValue('rnField476'); */
$lineasmoviles = $entry->GetFieldValue('rnField474');
$fibra0 = $entry->GetFieldValue('rnField375');
$fibra1 = $entry->GetFieldValue('rnField99');
$fibra2 = $entry->GetFieldValue('rnField100');
$fibra3 = $entry->GetFieldValue('rnField101');
$gonegociobasico = $entry->GetFieldValue('rnField376');
$gonegocioesencial = $entry->GetFieldValue('rnField377');
$gonegociosinlimites = $entry->GetFieldValue('rnField378');
$gonegociototal = $entry->GetFieldValue('rnField380');
$ilimitadas = $entry->GetFieldValue('rnField82');
$doscincuentaminutos = $entry->GetFieldValue('rnField83');
$datos = $entry->GetFieldValue('rnField84');
$cualtarifa1 = $entry->GetFieldValue('rnField833');
$cualtarifa2 = $entry->GetFieldValue('rnField834');
$cualtarifa3 = $entry->GetFieldValue('rnField835');
$cualtarifa4 = $entry->GetFieldValue('rnField836');
$cualtarifa5 = $entry->GetFieldValue('rnField837');
$cualtarifa6 = $entry->GetFieldValue('rnField838');
$cualtarifa7 = $entry->GetFieldValue('rnField839');
$cualtarifa8 = $entry->GetFieldValue('rnField840');
$cualtarifa9 = $entry->GetFieldValue('rnField841');
$cualtarifa10 = $entry->GetFieldValue('rnField842');
$terminales = $entry->GetFieldValue('rnField492');
$cualterminal1 = $entry->GetFieldValue('rnField190');
$cualterminal2 = $entry->GetFieldValue('rnField191');
$cualterminal3 = $entry->GetFieldValue('rnField192');
$cualterminal4 = $entry->GetFieldValue('rnField193');
$cualterminal5 = $entry->GetFieldValue('rnField194');
$cualterminal6 = $entry->GetFieldValue('rnField195');
$cualterminal7 = $entry->GetFieldValue('rnField213');
$cualterminal8 = $entry->GetFieldValue('rnField214');
$cualterminal9 = $entry->GetFieldValue('rnField215');
$cualterminal10 = $entry->GetFieldValue('rnField216');
$preciosyvaps1 = $entry->GetFieldValue('rnField843');
$preciosyvaps2 = $entry->GetFieldValue('rnField844');
$preciosyvaps3 = $entry->GetFieldValue('rnField845');
$preciosyvaps4 = $entry->GetFieldValue('rnField846');
$preciosyvaps5 = $entry->GetFieldValue('rnField847');
$preciosyvaps6 = $entry->GetFieldValue('rnField848');
$preciosyvaps7 = $entry->GetFieldValue('rnField849');
$preciosyvaps8 = $entry->GetFieldValue('rnField860');
$preciosyvaps9 = $entry->GetFieldValue('rnField861');
$preciosyvaps10 = $entry->GetFieldValue('rnField862');
$codigohtml = '<iframe src="http://prueba.com/index.php/nueva-hoja-de-pedido-de-prueba/" marginwidth="0" marginheight="0" name="ventana_iframe" scrolling="no" border="0" frameborder="0" width="230" height="60">
</iframe>';
$codigohtmlnuevaoferta = '<iframe src="http://prueba.com/index.php/nueva-oferta/" marginwidth="0" marginheight="0" name="ventana_iframe" scrolling="no" border="0" frameborder="0" width="230" height="60">
</iframe>';
$wpdb = new wpdb('root','PASSWD','DB','localhost');
$wpdb->insert('contact', array(
'id' => $crmid,
'n_o_m_b_r_e_e_m_p_r_e_s_a' => $NombreCliente,
'first_name' => $NombreCliente,
'modified_at' => $hoy,
'created_at' => $hoy,
'created_by_id' => $idusuario,
'administrador' => $Administrador,
'modified_by_id' => $idusuario,
'assigned_user_id' => $idusuario,
'correocliente' => $CorreoCliente,
'c_i_f' => $cif,
'p_a_q_u_e_t_e_c_o_n_t_r_a_t_a_d_o' => $paquete,
/* 'l_i_n_e_a_s_m_v_i_l_e_s' => $lineas, */
'fecha_de_creacin_o_f_e_r_t_a' => $hoy,
'yrgfh' => $codigohtml,
'n_u_e_v_a_o_f_e_r_t_a' => $codigohtmlnuevaoferta,
'i_d_c_l_i_e_n_t_e' => $crmid,
));
$wpdb->insert('entity_team', array(
'id' => $iddb,
'entity_id' => $crmid,
'team_id' => $ideequipo,
'entity_type' => $t,
'deleted' => $a,
));
$wpdb->insert('attachment', array(
'id' => $idoferta,
'name' => $idoferta,
'type' => "application/pdf",
'field' => "dOCUMENTACIL",
'created_at' => $hoy,
'role' => "Attachment",
'parent_id' => $crmid,
'parent_type' => "Contact",
'lineas_fibra' => $lineasfibra,
/* 'lineas_adsl' => $lineasadsl, */
'lineas_gobasico' => $gonegociobasico,
'lineas_goesencial' => $gonegocioesencial,
'lineas_gosinlimites' => $gonegociosinlimites,
'lineas_gototal' => $gonegociototal,
'lineas_ilimitadas' => $ilimitadas,
'lineas_datos' => $datos,
'lineas_250mins' => $doscincuentaminutos,
'fibra0' => $fibra0,
'fibra1' => $fibra1,
'fibra2' => $fibra2,
'fibra3' => $fibra3,
'lineas_moviles' => $lineasmoviles,
'tarifa1' => $cualtarifa1,
'tarifa2' => $cualtarifa2,
'tarifa3' => $cualtarifa3,
'tarifa4' => $cualtarifa4,
'tarifa5' => $cualtarifa5,
'tarifa6' => $cualtarifa6,
'tarifa7' => $cualtarifa7,
'tarifa8' => $cualtarifa8,
'tarifa9' => $cualtarifa9,
'tarifa10' => $cualtarifa10,
'terminal1' => $cualterminal1,
'terminal2' => $cualterminal2,
'terminal3' => $cualterminal3,
'terminal4' => $cualterminal4,
'terminal5' => $cualterminal5,
'terminal6' => $cualterminal6,
'terminal7' => $cualterminal7,
'terminal8' => $cualterminal8,
'terminal9' => $cualterminal9,
'terminal10' => $cualterminal10,
'preciosyvaps1' => $preciosyvaps1,
'preciosyvaps2' => $preciosyvaps2,
'preciosyvaps3' => $preciosyvaps3,
'preciosyvaps4' => $preciosyvaps4,
'preciosyvaps5' => $preciosyvaps5,
'preciosyvaps6' => $preciosyvaps6,
'preciosyvaps7' => $preciosyvaps7,
'preciosyvaps8' => $preciosyvaps8,
'preciosyvaps9' => $preciosyvaps9,
'preciosyvaps10' => $preciosyvaps10,
'terminales' => $terminales,
));
}Leave a comment:
-
just go to active theme-> function and place your code there
one thing is important is form id which makes problem check you formID
if ( '5' == event.detail.contactFormId ) //////// this is form id
put this code at the end of the function.php file of the active theme.
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer()
{
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7submit', function( event ) {
event.preventDefault();
if ( '5' == event.detail.contactFormId ) {
var inputs = event.detail.inputs;
for ( var i = 0; i < inputs.length; i++ )
{
if ( 'your-name' == inputs[i].name ) {
var yourname = inputs[i].value;
}
if ( 'your-email' == inputs[i].name ) {
var youremail = inputs[i].value;
}
if ( 'your-subject' == inputs[i].name ) {
var yoursubject = inputs[i].value;
}
}
alert('it is working now!!!');
var payloadData = {
firstName: yourname,
lastName: yoursubject,
emailAddress: youremail
};
var url = 'http://localhost:82/crm/api/v1/LeadCapture/f08780b335e74717f43368a08e423630';
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Accept', 'application/json');
xhr.onreadystatechange = function() {
if (this.readyState == XMLHttpRequest.DONE && this.status == 200) {
var containerElement = document.getElementById('web-to-lead-form-container');
containerElement.innerHTML = 'Sent';
alert('it is working fine');
}
}
xhr.onerror = function() {
webToLeadFormElement.submit.removeAttribute('disab led');
webToLeadFormIsSubmitted = false;
}
xhr.send(JSON.stringify(payloadData));
/* window.location.href = '/cf7-thank-you/?yourname='+yourname+'&youremail='+youremail+'&cf7 oldmethod='+cf7oldmethod; */
}
}, false );
</script>
<?php
}
aimal_gul(at)yahoo(dot)com //////// i can help you if not solved -
Newbie here.
Where do you exactly create or place these codes for contact form 7 forms? function.php?
Leave a comment:
-
We use:
Code in wordpress (after receive form data):
Code:$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"/?entryPoint=LeadCapture"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,($param_array + array('sessionId' => session_id() ))); curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Api-Key: XXX')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec($ch); curl_close($ch);
We don't use lead capture. We store client wordpress ssesion id for repeteadly requests.
Code:class LeadCapture extends \Espo\Core\EntryPoints\Base { public static $authRequired = true; public function run() { $entityManager = $this->getEntityManager(); $sessId = $_POST['sessionId']; $lead = $entityManager->getRepository('Lead')->where(array( 'siteSessionId' => $sessId ))->findOne(); if ($lead) { $note = $entityManager->getEntity('Note'); $note->set(array( 'parentId' => $lead->id, 'parentType' => 'Lead', 'post' => print_r($_POST, true), 'type' => 'Post' )); $entityManager->saveEntity($note); } else { $lead = $entityManager->getEntity('Lead'); $lead->set(array( 'source' => 'Web Site', 'status' => 'New', 'firstName' => ($_POST['submitter_name'] ?: $sessId), 'description' => print_r($_POST, true), 'phoneNumber' => $_POST['phone'], 'emailAddress' => $_POST['email'], 'siteSessionId' => $sessId )); $entityManager->saveEntity($lead); $case = $entityManager->getEntity('Case'); $case->set(array( 'name' => 'Обращение с сайта: '.$sessId, 'leadId' => ($lead->get('id')) )); $entityManager->saveEntity($case); } } }
Leave a comment:
-
look the documentation on contact form 7 docom, or something like that. I can't remember the name.
it is wpcf7send it I'm not wrong. -
Just to check how that works. From reading it I am guessing that:- The same code is inserted in every page
- When CF7 submits it fires the 'wpcf7submit' event
- You do check against the CF7 form ID and then process the correct fields
If so, how do you ensure that only correctly filled forms are sent to ESPO? Does the 'wpcf7submit' event fire on ever submit or only the ones where the data is valid?
Thanks for all the help.Leave a comment:
-
Code:wpcf7.cached = 0; document.addEventListener( 'wpcf7submit', function( event ) { event.preventDefault(); if ( '52' == event.detail.contactFormId ) { var inputs = event.detail.inputs; for ( var i = 0; i < inputs.length; i++ ) { if ( 'your-name' == inputs[i].name ) { var yourname = inputs[i].value; } if ( 'your-email' == inputs[i].name ) { var youremail = inputs[i].value; } if ( 'Interesse' == inputs[i].name ) { var Interesse = inputs[i].value; } if ( 'Empresa' == inputs[i].name ) { var Empresa = inputs[i].value; } if ( 'tel-79' == inputs[i].name ) { var telefone = inputs[i].value; } if ( 'your-subject' == inputs[i].name ) { var assunto = inputs[i].value; } if ( 'your-message' == inputs[i].name ) { var mensagem = inputs[i].value; } if ( 'Cargo' == inputs[i].name ) { var cargo = inputs[i].value; } if ( 'Cidade' == inputs[i].name ) { var cidade = inputs[i].value; } } var payloadData = { firstName: yourname, emailAddress: youremail, accountName: Empresa, description: 'Interesse: '+Interesse+'\r\n'+'Assunto: '+assunto+'\r\n'+'Texto: '+mensagem, phoneNumber: telefone, title: cargo, addressCity: cidade }; var url = 'https://crm.company.com/api/v1/LeadCapture/87f283dfsadfsdasdfdasfdas123d54'; var xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Accept', 'application/json'); xhr.onreadystatechange = function() { if (this.readyState == XMLHttpRequest.DONE && this.status == 200) { var containerElement = document.getElementById('web-to-lead-form-container'); containerElement.innerHTML = 'Sent'; } } xhr.onerror = function() { webToLeadFormElement.submit.removeAttribute('disabled'); webToLeadFormIsSubmitted = false; } xhr.send(JSON.stringify(payloadData)); /* window.location.href = '/cf7-thank-you/?yourname='+yourname+'&youremail='+youremail+'&cf7oldmethod='+cf7oldmethod; */ } }, false ); /* Espocrm Aimsun Download */ document.addEventListener( 'wpcf7submit', function( event ) { if ( '36589' == event.detail.contactFormId ) { var inputs = event.detail.inputs; for ( var i = 0; i < inputs.length; i++ ) { if ( 'your-name' == inputs[i].name ) { var yourname = inputs[i].value; var Interesse = 'Download Aimsun'; } if ( 'your-email' == inputs[i].name ) { var youremail = inputs[i].value; } if ( 'your-organization' == inputs[i].name ) { var Empresa = inputs[i].value; } if ( 'telefone' == inputs[i].name ) { var telefone = inputs[i].value; } if ( 'Cidade' == inputs[i].name ) { var cidade = inputs[i].value; } if ( 'Comentarioopcional' == inputs[i].name ) { var mensagem = inputs[i].value; } if ( 'Cargo' == inputs[i].name ) { var cargo = inputs[i].value; } } var payloadData = { firstName: yourname, emailAddress: youremail, accountName: Empresa, description: 'Interesse: '+Interesse+'\r\n'+'Texto: '+mensagem, phoneNumber: telefone, title: cargo, addressCity: cidade }; var url = 'https://crm.company.com/api/v1/LeadCapture/cacca828e71dsdsdsdsfdfdfdfdfdfdfe185ec'; var xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Accept', 'application/json'); xhr.onreadystatechange = function() { if (this.readyState == XMLHttpRequest.DONE && this.status == 200) { var containerElement = document.getElementById('web-to-lead-form-container'); containerElement.innerHTML = 'Sent'; } } xhr.onerror = function() { webToLeadFormElement.submit.removeAttribute('disabled'); webToLeadFormIsSubmitted = false; } xhr.send(JSON.stringify(payloadData)); /* window.location.href = '/cf7-thank-you/?yourname='+yourname+'&youremail='+youremail+'&cf7oldmethod='+cf7oldmethod; */ } }, false );
Leave a comment:
-
Can you share how you did it on CF7 please? I have been thinking though how to inject the PHP code at the right point, and am stumped.Leave a comment:
-
It's pretty easy to make a lead capture form: https://www.espocrm.com/documentatio...n/web-to-lead/Leave a comment:
-
It's pretty easy to make a lead capture form: https://www.espocrm.com/documentatio...n/web-to-lead/Leave a comment:
-
We are going through a similar situation. We currently capture leads on our web-site (which is WordPRess based, like 50% of the world apparently) and then re-key them into ESPO.
There are many form capture technologies on WordPress, many of which support plugins to CRM solutions. It would be great if ESPO could work with one of the forms vendors to have a direct plugin.
I am told by my web guy that the top forms technologies are:- Contact Forms 7
- WP Forms
- Gravity Forms
- Ninja Forms
Leave a comment:
-
with the last link you can find this file http://forum.espocrm.com/filedata/fetch?id=26006Leave a comment:
Leave a comment: