Gravity Forms is an advanced form builder for Wordpress websites and can be placed into the Wordpress functions.php file. These forms can integrate with Lead Gen & CRM forms.
Administrators | ✓ | |
Company Managers | ||
Marketing Managers | ||
Sales Managers | ||
Salespersons | ||
Jr. Salespersons |
The Form script that Lead Gen & CRM provides should not be placed on your page. It is only used to complete the procedures in this document.
The provided script is only used for reference, and it should not be on the page when connecting Gravity Forms via this method. The modified Wordpress .PHP code replaces what Lead Gen & CRM's Form script would normally do. If both are present, your form will not function as intended.
The procedures in this article assume that you have done the following:
Be aware that if you have existing Gravity Forms that were connected using Lead Gen & CRM's Gravity Forms Integration Tool, you will need to use the tool to generate code for new forms.
The Gravity Forms Integration Tool generates a block of code for each form you intend to add. If you were to use this tool for new forms, you would need to remove the .PHP code in the forms and add two hidden fields to each of your Gravity Forms.
Before you can connect Gravity Forms to Lead Gen & CRM, you need to create a third-party form. To create third-party forms, do the following:
Once you have created a third-party form in Lead Gen & CRM, you can begin connecting Gravity Forms. The connection process requires that you add both baseURI
and endpoint
information in connected forms. This information comes from the embed code generated by the created third party form in Lead Gen & CRM. To add baseURI
information to Gravity Forms, do the following:
leadgen_base_uri
baseURI
line in the embed code.baseURI
string, do not include the single quotation marks.baseURI
URL in the Default Value text field.Example code used:
![]() | ![]() |
---|
Be aware that endpoint
information is still needed to complete the connection process.
Once you have added baseURI
information to Gravity Forms, you will need to add endpoint
information. This information comes from the embed code generated by the created third party form in Lead Gen & CRM. To add endpoint
information to Gravity Forms, do the following:
leadgen_endpoint
endpoint
line in the embed code.endpoint
string, do not include the single quotation marks.endpoint
string in the Default Value text field.Example code used:
![]() | ![]() |
---|
Once you have added baseURI
and endpoint
information to Gravity Forms, you will need to enable Wordpress to capture it, which requires some additional code.
The simplest way to do this is by uploading the plugin file found here. Note that this is offered as a way to add the code to WordPress, and the other steps are necessary, aside from copying the PHP code. If there is any issue with using this plugin on your setup, your developer will need to explore adding the PHP code below manually.
If this gives you issues, or you prefer to add the code in your own way, please see the steps below. By using either the plugin or a child theme, it will prevent the code from being removed if your theme updates its functions.php file.
Note that this is only required if not using the plugin as noted above. If using the plugin, please proceed to the Mapping Third Party Forms section below.
There are certain things to consider when adding .PHP code to Wordpress, however:
To modify Wordpress .PHP code, do the following:
Important: Changes to the functions.php file in Wordpress can result in your site crashing. Be sure you have FTP access in order to backup and revert to your old functions.php file if needed.
add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 ); function post_to_third_party( $entry, $form ){ if ( rgar( $entry, 'status' ) === 'spam' ) { return false; } $body = []; function dupeCheck($fieldName, $bodyData) { $cleanLabel = substr(preg_replace("/[^a-zA-Z0-9]+/", "", $fieldName), 0, 24); for ($x = 0; $x <= 20; $x++) { if(array_key_exists($cleanLabel, $bodyData)) { $cleanLabel = $cleanLabel . $x; } else { break; } } return $cleanLabel; } $formFields = $form['fields']; foreach($formFields as $formField): if($formField['label'] == 'leadgen_base_uri' || $formField['label'] == 'sharpspring_base_uri') { $base_uri = rgar( $entry, $formField['id']); $sendToLeadGen = true; } elseif($formField['label'] == 'leadgen_endpoint' || $formField['label'] == 'sharpspring_endpoint') { $post_endpoint = rgar( $entry, $formField['id']); } elseif($formField['label'] == 'support_test') { $support_endpoint = rgar( $entry, $formField['id']); $testMode = true; } elseif($formField['type'] == 'multiselect') { $fieldNumber = $formField['id']; $fieldLabel = dupeCheck($formField['label'], $body); $tempValue = rgar ( $entry, strval($fieldNumber) ); $trimmedValue = str_replace('[', '', $tempValue); $trimmedValue = str_replace(']', '', $trimmedValue); $trimmedValue = str_replace('"', '', $trimmedValue); $body[preg_replace("/[^a-zA-Z0-9]+/", "", $fieldLabel)] = $trimmedValue; } elseif($formField['inputs']) { if($formField['type'] == 'checkbox') { $fieldNumber = $formField['id']; $fieldLabel = dupeCheck($formField['label'], $body); $checkBoxField = GFFormsModel::get_field( $form, strval($fieldNumber) ); $tempValue = is_object( $checkBoxField ) ? $checkBoxField->get_value_export( $entry ) : ''; $trimmedValue = str_replace(', ', ',', $tempValue); $body[preg_replace("/[^a-zA-Z0-9]+/", "", $fieldLabel)] = $trimmedValue; } elseif($formField['type'] == 'time') { $fieldNumber = $formField['id']; $fieldLabel = dupeCheck($formField['label'], $body); $body[preg_replace("/[^a-zA-Z0-9]+/", "", $fieldLabel)] = rgar( $entry, strval($fieldNumber) ); } elseif($formField['type'] == 'date') { $fieldNumber = $formField['id']; $fieldLabel = dupeCheck($formField['label'], $body); $body[preg_replace("/[^a-zA-Z0-9]+/", "", $fieldLabel)] = rgar( $entry, strval($fieldNumber) ); } else { foreach($formField['inputs'] as $subField): $fieldLabel = dupeCheck($subField['label'], $body); $fieldNumber = $subField['id']; $body[preg_replace("/[^a-zA-Z0-9]+/", "", $fieldLabel)] = rgar( $entry, strval($fieldNumber) ); endforeach; } } else { $fieldNumber = $formField['id']; $fieldLabel = dupeCheck($formField['label'], $body); $body[preg_replace("/[^a-zA-Z0-9]+/", "", $fieldLabel)] = rgar( $entry, strval($fieldNumber) ); }; endforeach; $body['form_source_url'] = $entry['source_url']; $body['trackingid__sb'] = $_COOKIE['__ss_tk']; //DO NOT CHANGE THIS LINE... it collects the tracking cookie to establish tracking $post_url = $base_uri . $post_endpoint; if($sendToLeadGen) { $request = new WP_Http(); $response = $request->post( $post_url, array( 'body' => $body ) ); } if($testMode) { $request2 = new WP_Http(); $response2 = $request2->post( $support_endpoint, array( 'body' => $body ) ); $request3 = new WP_Http(); $response3 = $request3->post( $support_endpoint, array( 'body' => $entry ) ); $request4 = new WP_Http(); $response4 = $request4->post( $support_endpoint, array( 'body' => $form ) ); } } ?>
Once you have created a third party form, added third party form embed code, and modified Wordpress' functions.php file, you can map the fields in the third party form. Mapping form fields provides Lead Gen & CRM with information on what those form fields refer to. To map third party forms, do the following:
Whenever you fill out the form for the first time, you generate mapping data. As such, do not expect the lead to appear in the system until after the first entry. The second person to fill out the form will be imported as a lead.
When mapping fields and connecting Gravity Forms, consider the following:
Copyright © 2025 · All Rights Reserved · Constant Contact · Privacy Center