Capture WPForms to JetPack CRM Plugin
This plugin captures selected data from a Standard Form in WPForms and adds it to JetPack CRM. Any customization to a Standard Form will not be captured without custom coding to the plugin.
- Download the plugin
- To install in your WordPress, make sure you have JetPack CRM and WPForms installed first.
- Be sure your WordPress and PHP versions are correct (see PHP requirements below)
- Download the file to your computer by clicking here: https://randymartinsen.net/capture-wpforms-jetcrm.zip
- In WordPress, select Add New in Plugins menu, then select “Upload Plugin” and upload the file from your computer
- For detailed instructions click here.
PHP Code:
<?php
/**
* Plugin Name: Capture WPForms to Jetpack CRM
* Plugin URI: https://randymartinsen.net/capture-wpforms-jetpackcrm/
* Description: Use WPForms to collect customer info and import to ZBSCRM.
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 5.6
* Author: Randy Martinsen
* Author URI: https://randymartinsen.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: capture-wpforms-jetcrm
*/
// Do not call this file directly.
defined( ‘ABSPATH’ ) || exit;
// Update version.
register_activation_hook( __FILE__, function() {
update_option( ‘cwjc_version’, ‘1.0.0’ );
} );
// Save a lead to the Jetpack CRM when a user comes from WPForms.
function cwjc_save_wpforms_entry_to_jetpack_crm( $fields ) {
$data = array(
‘zbsc_status’ => ‘Customer’,
‘zbsc_notes’ => ‘Capture WPForms Customer’,
);
foreach( $fields as $field ) {
if ( ! in_array( $field[‘type’], array( ‘name’, ’email’ ) ) ) {
// continue;
}
if ( ‘name’ === $field[‘type’] ) {
list( $first_name, $last_name ) = explode( ‘ ‘, sanitize_text_field( $field[‘value’] ) );
$data[‘zbsc_fname’] = $first_name;
$data[‘zbsc_lname’] = $last_name;
}
if ( ’email’ === $field[‘type’] ) {
$data[‘zbsc_email’] = sanitize_email( $field[‘value’] );
}
if ( ‘phone’ === $field[‘type’] ) {
$data[‘zbsc_mobtel’] = sanitize_text_field( $field[‘value’] );
}
if ( ‘textarea’ === $field[‘type’] ) {
$data[‘zbsc_notes’] = sanitize_textarea_field( $field[‘value’] );
}
if ( ‘address’ === $field[‘type’] ) {
$data[‘zbsc_addr1’] = sanitize_text_field( $field[‘address1’] );
$data[‘zbsc_addr2’] = sanitize_text_field( $field[‘address2’] );
$data[‘zbsc_city’] = sanitize_text_field( $field[‘city’] );
$data[‘zbsc_county’] = sanitize_text_field( $field[‘state’] );
$data[‘zbsc_postcode’] = sanitize_text_field( $field[‘postal’] );
$data[‘zbsc_country’] = sanitize_text_field( $field[‘country’] );
}
}
if ( empty( $data[‘zbsc_email’] ) || ! function_exists( ‘zeroBS_integrations_addOrUpdateCustomer’ ) ) {
return;
}
zeroBS_integrations_addOrUpdateCustomer( ‘form’, $data[‘zbsc_email’], $data );
}
add_action( ‘wpforms_process_entry_save’, ‘cwjc_save_wpforms_entry_to_jetpack_crm’ );
If you have questions click here to contact me directly.