This guide will show you how to add a new lead to Zoho CRM when a user submits a Quform form. In this guide we’ll create a new plugin to contain the code needed for the integration to work.

Step 1 – create a WordPress plugin

Create a new folder named quform-zoho-integration and inside it create a file named quform-zoho-integration.php

Inside the quform-zoho-integration.php file add the following code.

1
2
3
4
5
6
7
8
910
11
1213
1415
16
17
18
19
20
21
22
23
2425
26
27
28
29
30
31
32
33
34
<?php
 
/*
 * Plugin Name: Quform Zoho Integration
 * Description: Add leads to Zoho CRM from Quform forms.
 * Version: 1.0
 */
 
add_filter('quform_post_process_1', function (array $result, Quform_Form $form) {    require 'vendor/autoload.php';
 
    $client = new CristianPontes\ZohoCRMClient\ZohoCRMClient('Leads', 'yourAuthToken', 'com'); 
    $name = $form->getValue('quform_1_3');    $firstName = $name[2];
    $lastName = $name[4];
 
    try {
        $client->insertRecords()
            ->setRecords(array(
                array(
                    'First Name' => $firstName,
                    'Last Name' => $lastName,
                    'Email' => $form->getValue('quform_1_4')                )
            ))->request();
    } catch (Exception $e) {
        if (defined('WP_DEBUG') && WP_DEBUG) {
            Quform::log($e);
        }
    }
 
    return $result;
}, 10, 2);
<?php

/*
 * Plugin Name: Quform Zoho Integration
 * Description: Add leads to Zoho CRM from Quform forms.
 * Version: 1.0
 */

add_filter('quform_post_process_1', function (array $result, Quform_Form $form) {
    require 'vendor/autoload.php';

    $client = new CristianPontes\ZohoCRMClient\ZohoCRMClient('Leads', 'yourAuthToken', 'com');

    $name = $form->getValue('quform_1_3');
    $firstName = $name[2];
    $lastName = $name[4];

    try {
        $client->insertRecords()
            ->setRecords(array(
                array(
                    'First Name' => $firstName,
                    'Last Name' => $lastName,
                    'Email' => $form->getValue('quform_1_4')
                )
            ))->request();
    } catch (Exception $e) {
        if (defined('WP_DEBUG') && WP_DEBUG) {
            Quform::log($e);
        }
    }

    return $result;
}, 10, 2);
1
2
3
4
5
6
7
8
9
10
11
12
1314
1516
17
18
19
20
21
22
23
24
2526
27
28
29
30
31
32
33
34
35
36
<?php
 
/*
 * Plugin Name: Quform Zoho Integration
 * Description: Add leads to Zoho CRM from Quform forms.
 * Version: 1.0
 */
 
function my_zoho_integration(array $result, Quform_Form $form)
{
    require 'vendor/autoload.php';
 
    $client = new CristianPontes\ZohoCRMClient\ZohoCRMClient('Leads', 'yourAuthToken', 'com'); 
    $name = $form->getValue('quform_1_3');    $firstName = $name[2];
    $lastName = $name[4];
 
    try {
        $client->insertRecords()
            ->setRecords(array(
                array(
                    'First Name' => $firstName,
                    'Last Name' => $lastName,
                    'Email' => $form->getValue('quform_1_4')                )
            ))->request();
    } catch (Exception $e) {
        if (defined('WP_DEBUG') && WP_DEBUG) {
            Quform::log($e);
        }
    }
 
    return $result;
}
add_filter('quform_post_process_1', 'my_zoho_integration', 10, 2);
<?php

/*
 * Plugin Name: Quform Zoho Integration
 * Description: Add leads to Zoho CRM from Quform forms.
 * Version: 1.0
 */

function my_zoho_integration(array $result, Quform_Form $form)
{
    require 'vendor/autoload.php';

    $client = new CristianPontes\ZohoCRMClient\ZohoCRMClient('Leads', 'yourAuthToken', 'com');

    $name = $form->getValue('quform_1_3');
    $firstName = $name[2];
    $lastName = $name[4];

    try {
        $client->insertRecords()
            ->setRecords(array(
                array(
                    'First Name' => $firstName,
                    'Last Name' => $lastName,
                    'Email' => $form->getValue('quform_1_4')
                )
            ))->request();
    } catch (Exception $e) {
        if (defined('WP_DEBUG') && WP_DEBUG) {
            Quform::log($e);
        }
    }

    return $result;
}
add_filter('quform_post_process_1', 'my_zoho_integration', 10, 2);

Step 2 – install the Zoho CRM PHP client

Next you need to install the Zoho CRM PHP client using composer. You can do this on your computer or on the web server. In a terminal navigate to the directory of the plugin you created in Step 1, then run this command:

composer require cristianpontes/zoho-crm-client-php

This will install all required files into the vendor folder within the plugin. Upload the quform-zoho-integration folder to the web server at wp-content/plugins then go to the Plugins page within WordPress and activate the plugin Quform Zoho Integration and you’re done.

Troubleshooting

If the integration does not work, try temporarily enabling debug logging then submit the form again and check for an error message in the wp-content/debug.log file.

Be inspired. © 2019 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy