Automating Lead Intake: Linking Elementor Forms and Contact Form 7 to Zoho and HubSpot CRMs
Stop copy-pasting leads manually. Learn how to map WordPress form submissions directly to Zoho and HubSpot CRM APIs using custom PHP hooks.
For B2B marketing websites, contact forms are the primary point of customer contact. However, many sales teams still manually copy lead information from email notifications and paste it into their CRMs. This slow process delays response times and can result in lost opportunities.
While plugins like Zapier or WPForms offer prebuilt CRM integrations, they charge recurring monthly fees and offer limited control over field mapping and data validation.
A cleaner, faster solution is linking forms directly to your Zoho or HubSpot CRM using WordPress REST API hooks.
This guide details how to write secure PHP handlers to capture form submissions, authenticate API connections, and sync leads.
1. Mapping the Lead Data Structure
Before coding, map your WordPress form fields to the corresponding API fields in your CRM.
| WordPress Form ID | HubSpot API Parameter | Zoho CRM field Name |
|---|---|---|
form_name | firstname | First_Name |
form_email | email | Email |
form_phone | phone | Phone |
form_message | message | Description |
2. Syncing Elementor Forms to HubSpot CRM API
Elementor Forms features a built-in action hook called elementor_pro/forms/new_record that triggers after a form validates successfully.
Add this PHP handler to your theme's functions.php to send leads to HubSpot:
`php
add_action( 'elementor_pro/forms/new_record', 'sync_elementor_lead_to_hubspot', 10, 2 );
function sync_elementor_lead_to_hubspot( $record, $handler ) {
// Only target your specific B2B Contact Form
$form_name = $record->get_form_settings( 'form_name' );
if ( 'b2b_contact' !== $form_name ) return;
$raw_fields = $record->get_fields();
$fields = array();
foreach ( $raw_fields as $id => $field ) {
$fields[$id] = sanitize_text_field( $field['value'] );
}
// Format payload for HubSpot Contact API
$payload = array(
'properties' => array(
'email' => $fields['form_email'],
'firstname' => $fields['form_name'],
'phone' => $fields['form_phone'],
'message' => $fields['form_message']
)
);
// Dispatch webhook to HubSpot API
$response = wp_remote_post( 'https://api.hubapi.com/crm/v3/objects/contacts', array(
'headers' => array(
'Authorization' => 'Bearer ' . HUBSPOT_ACCESS_TOKEN,
'Content-Type' => 'application/json'
),
'body' => json_encode( $payload )
));
if ( is_wp_error( $response ) ) {
error_log( 'HubSpot lead synchronization failed: ' . $response->get_error_message() );
}
}
`
3. Syncing Contact Form 7 to Zoho CRM API
Contact Form 7 utilizes the wpcf7_before_send_mail hook, which fires before the plugin sends its email notification.
Step 1: Obtain a Zoho OAuth Access Token
Zoho CRM requires a dynamic access token generated via a refresh token. Add a helper function to retrieve this:
`php
function get_zoho_access_token() {
$response = wp_remote_post( 'https://accounts.zoho.com/oauth/v2/token', array(
'body' => array(
'refresh_token' => ZOHO_REFRESH_TOKEN,
'client_id' => ZOHO_CLIENT_ID,
'client_secret' => ZOHO_CLIENT_SECRET,
'grant_type' => 'refresh_token'
)
));
$body = json_decode( wp_remote_retrieve_body( $response ), true );
return isset( $body['access_token'] ) ? $body['access_token'] : '';
}
`
Step 2: Push Submission Data to Zoho CRM
Hook into the submission process and push the lead data:
`php
add_action( 'wpcf7_before_send_mail', 'sync_cf7_lead_to_zoho' );
function sync_cf7_lead_to_zoho( $contact_form ) {
$submission = WPCF7_Submission::get_instance();
if ( ! $submission ) return;
$posted_data = $submission->get_posted_data();
$access_token = get_zoho_access_token();
if ( ! $access_token ) return;
$lead_data = array(
'data' => array(
array(
'Last_Name' => sanitize_text_field( $posted_data['your-name'] ),
'Email' => sanitize_email( $posted_data['your-email'] ),
'Description' => sanitize_text_field( $posted_data['your-message'] ),
'Lead_Source' => 'Website Contact Form'
)
)
);
wp_remote_post( 'https://www.zohoapis.com/crm/v2/Leads', array(
'headers' => array(
'Authorization' => 'Zoho-oauthtoken ' . $access_token,
'Content-Type' => 'application/json'
),
'body' => json_encode( $lead_data )
));
}
`
4. Implementing Offline Error Queues
If your CRM goes offline, lead submissions should not be lost. Write a fallback routine that stores failed lead submissions in your local WordPress database as custom post types or options, and schedules a retry task to sync them once the API connection is restored.
Connecting your contact forms directly to your CRM API speeds up sales follow-ups, protects lead data privacy, and eliminates Zapier transaction costs.
Related posts
AI-Assisted Software Development: Governance and Review Checklist
A practical governance and review checklist for teams using AI coding assistants without losing control of quality, security, privacy or maintainability.
Read article →
API Integration Guide for Business Owners
A practical API integration guide for business owners planning CRM, payment, accounting, booking, dashboard, e-commerce or automation integrations.
Read article →
Appointment Booking Automation for Service Businesses
A practical appointment booking automation guide for service businesses that need cleaner scheduling, reminders, payments, intake forms and follow-up.
Read article →
Author
Anushka Dahanayake
Anushka Dahanayake is the founder of ANUSHKA DAHANAYAKE (PVT) LTD, building SEO-driven content, digital services, and revenue platforms for businesses in Sri Lanka and worldwide.