Here’s a WordPress plugin that will allow you to send Contact Form 7 submissions to a 3rd-party Service like a CRM. Multiple configurable services, custom field mapping, pre/post processing.
As taken from the readme
file:
Description
Send Contact Form 7 Submissions to a 3rd-party Service, like a CRM. Multiple configurable services, custom field mapping. Provides hooks and filters for pre/post processing of results. Allows you to send separate emails, or attach additional results to existing emails. Comes with a couple examples of hooks for common CRMs (listrak, mailchimp, salesforce).
The plugin essentially makes a remote request (POST) to a service URL, passing along remapped form submission values.
Includes hidden field plugin from Contact Form 7 Modules: Hidden Fields. Based on idea by Alex Hager “How to Integrate Salesforce in Contact Form 7”
Installation
- Unzip, upload plugin folder to your plugins directory (
/content/plugins/
) - Make sure Contact Form 7 is installed
- Activate plugin
- Go to new admin subpage “3rdparty Services” under the CF7 “Contact” menu and configure services + field mapping.
Please note that this includes an instance of hidden.php
, which is part of the “Contact Form 7 Modules” plugin — this will show up on the Plugin administration page, but is included automatically, so you don’t need to enable it. This file will only be included if you don’t already have the module installed.
Frequently Asked Questions
How do I add / configure a service?
See Screenshots for visual examples.
Essentially,
- Name your service
- Enter the submission URL — if your “service” provides an HTML form, you would use the form action here
- Choose which forms will submit to this service (“Attach to Forms”)
- Set the default “success condition”, or leave blank to ignore (or if using post processing, see Hooks – this just looks for the provided text in the service response, and if present assumes “success”
- Allow hooks for further processing – unchecking it just saves minimal processing power, as it won’t try to execute filters
- Map your form submission values (from the CF7 field tags) to expected fields for your service. 1:1 mapping given as the name of the CF7 field and the name of the 3rdparty field; you can also provide static values by checking the “Is Value?” checkbox and providing the value in the “CF7 Field” column.
- Add, remove, and rearrange mapping – basically just for visual clarity.
- Use the provided hooks (as given in the bottom of the service block)
- Add new services as needed
How can I pre/post process the request/results?
See section Hooks. See plugin folder /3rd-parties
for example code for some common CRMs, which you can either directly include or copy to your code.
Screenshots
- Admin page – create multiple services, set up debugging/notice emails, example code
- Sample service – mailchimp integration, with static and mapped values
- Customized thank-you page
Hooks
add_action('Cf73rdPartyIntegration_service_a#',...
- hook for each service, indicated by the
#
– this is given in the ‘Hooks’ section of each service - provide a function which takes
$response, &$results
as arguments - allows you to perform further processing on the service response, and directly alter the processing results, provided as
array('success'=>false, 'errors'=>false, 'attach'=>'', 'message' => '');
, where- success =
true
orfalse
– change whether the service request is treated as “correct” or not - errors = an array of error messages to return to the form
- attach = text to attach to the end of the email body
- message = the message notification shown (from CF7 ajax response) below the form
- success =
- note that the basic “success condition” may be augmented here by post processing
- hook for each service, indicated by the
add_filter('Cf73rdPartyIntegration_service_filter_post_#, ...
- hook for each service, indicated by the
#
– this is given in the ‘Hooks’ section of each service - allows you to programmatically alter the request parameters sent to the service
- hook for each service, indicated by the
Basic examples provided directly on plugin Admin page (collapsed box “Examples of callback hooks”). Code samples for common CRMS included in the /3rd-parties
plugin folder.