This guide will show you how to add a new contact to GetResponse 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-getresponse and inside it create a file named quform-getresponse.php
Inside the quform-getresponse.php file add the following code.
1 2 3 4 5 6 7 8 910 11 12 13 14 1516 17 18 192021 2223 24 25 26 27 28 29 30 31 32 33 | <?php /* * Plugin Name: Quform GetResponse Integration * Description: Add contacts to GetResponse from Quform forms. * Version: 1.0 */ add_filter('quform_post_process_1', function (array $result, Quform_Form $form){ if (!class_exists('GetResponse')) { require_once dirname(__FILE__) . '/GetResponseAPI3.class.php'; } $getresponse = new GetResponse('yourApiKey'); try { $result = $getresponse->addContact(array( 'name' => $form->getValueText('quform_1_3'), 'email' => $form->getValue('quform_1_4'), 'campaign' => array( 'campaignId' => 'yourCampaignId' ), 'ipAddress' => Quform::getClientIp() )); } catch (Exception $e) { if (defined('WP_DEBUG') && WP_DEBUG) { Quform::log($e); } } return $result; }, 10, 2); |
<?php /* * Plugin Name: Quform GetResponse Integration * Description: Add contacts to GetResponse from Quform forms. * Version: 1.0 */ add_filter('quform_post_process_1', function (array $result, Quform_Form $form) { if (!class_exists('GetResponse')) { require_once dirname(__FILE__) . '/GetResponseAPI3.class.php'; } $getresponse = new GetResponse('yourApiKey'); try { $result = $getresponse->addContact(array( 'name' => $form->getValueText('quform_1_3'), 'email' => $form->getValue('quform_1_4'), 'campaign' => array( 'campaignId' => 'yourCampaignId' ), 'ipAddress' => Quform::getClientIp() )); } catch (Exception $e) { if (defined('WP_DEBUG') && WP_DEBUG) { Quform::log($e); } } return $result; }, 10, 2);
- On line 9, replace the number
1
with the form ID - On line 15, replace
yourApiKey
with your GetResponse API key, see Step 2 below - On line 19, replace
1_3
with the Name element unique ID - On line 20, replace
1_4
with the Email element unique ID - On line 22, replace
yourCampaignId
the GetResponse campaign ID, see Step 2 below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1516 17 18 192021 2223 24 25 26 27 28 29 30 31 32 33 34 | <?php /* * Plugin Name: Quform GetResponse Integration * Description: Add contacts to GetResponse from Quform forms. * Version: 1.0 */ function my_getresponse_integration(array $result, Quform_Form $form) { if (!class_exists('GetResponse')) { require_once dirname(__FILE__) . '/GetResponseAPI3.class.php'; } $getresponse = new GetResponse('yourApiKey'); try { $result = $getresponse->addContact(array( 'name' => $form->getValueText('quform_1_3'), 'email' => $form->getValue('quform_1_4'), 'campaign' => array( 'campaignId' => 'yourCampaignId' ), 'ipAddress' => Quform::getClientIp() )); } catch (Exception $e) { if (defined('WP_DEBUG') && WP_DEBUG) { Quform::log($e); } } return $result; } add_filter('quform_post_process_1', 'my_getresponse_integration', 10, 2); |
<?php /* * Plugin Name: Quform GetResponse Integration * Description: Add contacts to GetResponse from Quform forms. * Version: 1.0 */ function my_getresponse_integration(array $result, Quform_Form $form) { if (!class_exists('GetResponse')) { require_once dirname(__FILE__) . '/GetResponseAPI3.class.php'; } $getresponse = new GetResponse('yourApiKey'); try { $result = $getresponse->addContact(array( 'name' => $form->getValueText('quform_1_3'), 'email' => $form->getValue('quform_1_4'), 'campaign' => array( 'campaignId' => 'yourCampaignId' ), 'ipAddress' => Quform::getClientIp() )); } catch (Exception $e) { if (defined('WP_DEBUG') && WP_DEBUG) { Quform::log($e); } } return $result; } add_filter('quform_post_process_1', 'my_getresponse_integration', 10, 2);
- On line 15, replace
yourApiKey
with your GetResponse API key, see Step 2 below - On line 19, replace
1_3
with the Name element unique ID - On line 20, replace
1_4
with the Email element unique ID - On line 22, replace
yourCampaignId
the GetResponse campaign ID, see Step 2 below - On line 34, replace the number
1
with the form ID
Step 2 – get your GetResponse API key and campaign ID
API key
In GetResponse go to My Account → Account Details → API & OAuth to find the API key.
Campaign ID
In GetResponse from the Dashboard click on the switch campaign menu and click Campaign List.
On the campaign list what you want is the Token value shown below the campaign name. You only want the letters and numbers of the token, not including the colon or comma (for example in the image below the token is aBCde
).
Step 3 – install the GetResponse PHP client
Download this file and save it as GetResponseAPI3.class.php into the plugin folder you created in Step 1 quform-getresponse. Upload the quform-getresponse folder to the web server at wp-content/plugins then go to the Plugins page within WordPress and activate the plugin Quform GetResponse Integration and you’re done.
Step 4 – disable confirmed opt-in (optional)
By default subscribers will not appear in your Contacts list straight away, they will be sent an email to confirm their subscription and only after confirmation will they appear in the list. To skip this you can disable confirmed opt-in for API subscriptions. From the GetResponse Dashboard click the settings icon next to the campaign in the top right corner.
Then go to the Permission tab and uncheck the option Api subscriptions.
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.