Gravity Forms Basic/Pro
Overview
To connect One Tribe to Gravity forms you will require the following:
- A Wordpress site
- Gravity forms plugin
- Being comfortable installing plugins
- Being comfortable configuring the code on your Wordpress site
Step 1: Install Gravity forms
- Download the Gravity forms plugin from you Gravity forms account
- Login here → https://www.gravityforms.com/wp-login.php
- Navigate to your account on Gravity forms and select 'Your Downloads'.
- Download the Gravity forms plugin
- Login to your WordPress admin dashboard.
- Go to Plugins > Add New.
- Then go to “Upload plugin”.
Within this page, click the Upload Plugin button and select the Choose File button. Then, locate the Gravity Forms zip file, select it and click the Install Now button. WordPress will now automatically handle the installation. If you're already familiar with installing and activating WordPress plugins, you can skip to the second step.
Do you see only a gravity forms folder?
Visit docs.gravityforms.com/my-download-is-not-a-zipfile. Once complete, be sure to click - Click on the Activate Plugin button.
- On the WordPress admin menu, go to Forms > Settings.
- On the Settings page, click on the License tab.
- Enter your Gravity Forms license key (if pro or elite)
- Click the Activate License button.
Step 2: Install Code Snippets
In order to prevent the webhook from being reset if you change theme or update the theme of your Wordpress site we suggest installing a code insertion plugin. This will persist the changes between updates and template changes.
We suggest a plugin like Code Snippets (https://wordpress.org/plugins/code-snippets/). There is a free version that works perfectly for this situation.
- Click “Plugins”
- Click “Add new”
- Search “Code Snippets”
- Click “Install Now”
Step 3: Create form
- Click on “Forms” on the left navigation bar
- Click on “New Form” in the sub menu
- Add a title for your form in the pop up
- Click “Create Form”
- Add all components you need for your form
- Click “Save form” in the top right when done
- Return to the form page and make note of your Form ID
(If this is your first form it should be 1)
Step 4: Add Webhook code
- Navigate and click on “Snippets” on the menu on the left
- Click “Add New” at the top
- Copy the code below into the box
- See '4. Edit webhook' below in order to fine tune your webhook.
// called on form submission & fires function to send to One Tribe
add_action( "gform_after_submission_1", "post_to_one_tribe", 10, 2 );
// function to send the data to One Tribe with your unique merchantID
function post_to_one_tribe( $entry, $form ){
$endpoint_url = "https://staging-api.onetribeglobal.com/direct/webhook/gravity-forms/submission/bOpxVgsXVmsaBdpvadvHMCx";
$body = '';
GFCommon::log_debug( "gform_after_submission: body => " . print_r( $body, true ) );
$response = wp_remote_post( $endpoint_url, array( "body" => $body ) );
GFCommon::log_debug( "gform_after_submission: response => " . print_r( $response, true ) );
}
- Edit webhook
- Change ID of form
You can change which form to have the webhook fire on by updating the suffix of the function name. The function name being gform_after_submission_1 or gform_after_submission. It is the first half, before the comma and after add_action( . For example, if you wanted to send webhooks only for the form with the ID of 2 then you would update the name of the function from:
- Change ID of form
// origial
- add_action( "gform_after_submission_1", "post_to_one_tribe", 10, 2 );
- php
- Update to this
// new (updated)
- add_action( "gform_after_submission_2", "post_to_one_tribe", 10, 2 );
- php
- The _[id] is the id of the form it will activate on.
- Apply to all forms
- You can change whether to apply this action to all forms, or just a single form based on the form ID.
- To apply it to all forms remove _1 from the name of the function (refer to step A above for what the function is) as below.
- add_action( "gform_after_submission", "post_to_one_tribe", 10, 2 );
- php
- Save the code and activate the snippet.
Step 5: Check integration
Congratulations! Integration installation is now complete.
Now when the form is submitted it will send information to OneTribe that allows us to record 1 unit for each form submission that will add trees to your account, the trees are denoted depending which plan you are on.
- To finish this integration, you will need to check the integration.
- This is achieved by clicking the “Check Integration” button below.
- Please leave the popup open whilst in a separate window please submit your form.
- If the form is successfully tracked the popup in the other window will let you know.
Congratulations you have successfully integrated!
Update Integration