Introduction

This section contains information that will guide you to integrate Leadtrekker with most of the common Content Management Systems (CMS) such as WordPress and Drupal.

Dynamic Posted Key Names

Forms used on Content Management Systems often assign dynamic key names to the form elements being posted. You should know what the key names of the posted elements are in order to specify them in the API code. You can find these key names and their values by using browser debugger such as Google Chrome's DevTools.

WordPress

WordPress is a free and open-source Content Management System based on PHP and MySQL. Features include a plugin architecture and a template system.

Website Backups

You should always make backups of your Website before attempting to implement Leadtrekker's API.

WordPress Hooks

In WordPress theme and development, Hooks are functions that can be applied to an Action or a Filter in WordPress. Actions and Filters in WordPress are functions that can be modified by theme and plugin developers to change the default WordPress functionality. Functions used to modify Actions/Filters in WordPress can be hooked into WordPress. However, it is important to note that actions and filters are not the same thing. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. But they are different in functionality and how they behave.

For each of our integrations we will need to create a hook. This can be done by editing the file called functions.php from within the WordPress admin back-end and adding the sample code based on the form plugin you use on your WordPress site.

To edit the functions.php file on your wordpress site, follow these two simple steps.

  1. Log into your WordPress Admin Console.
  2. Click on Appearence and then click Theme Editor.
  3. Under the Theme Files section look for the file called Theme Functions (functions.php).
  4. Add your Leadtrekker code to the bottom of the file. Save the file when done and test your integration by submitting a form.

Contact Form 7

The following is an example hook when using the Wordpress Contact Form 7 plugin.


add_filter('wpcf7_before_send_mail', 'wp_leadtrekker', 10, 1);

function wp_leadtrekker($contact_form) 
{
  /**
  * Uncomment some of the lines below to see more 
  * debugging information that might be useful to find 
  * the posted key names and their values of the 
  * elements in the posted form.
  */
  //print_r($_POST);
  //print_r($contact_form);  

  /**
  * Your Leadtrekker createlead code should follow this comment.
  * Please refer to the Getting Started section in the documentation for more information
  * on creating leads.
  * @see https://docs.leadtrekker.com
  */
}

Formidable

The following is an example hook when using the Wordpress Formidable plugin.


add_action('frm_after_create_entry', 'wp_leadtrekker', 30, 2);

function wp_leadtrekker($entry_id, $form_id)
{
  /**
  * Uncomment some of the lines below to see more 
  * debugging information that might be useful to find 
  * the posted key names and their values of the 
  * elements in the posted form.
  */
  //print_r($_POST);
  //print_r($form_id);
  //print_r($entry_id);

  /**
  * Your Leadtrekker createlead code should follow this comment.
  * Please refer to the Getting Started section in the documentation for more information
  * on creating leads.
  * @see https://docs.leadtrekker.com
  */
}

wpforms

The following is an example hook when using the Wordpress wpforms plugin.


add_action('wpforms_process_complete', 'wp_leadtrekker', 10, 4);

function wp_leadtrekker($fields, $entry, $form_data, $entry_id)
{
  /**
  * Uncomment some of the lines below to see more 
  * debugging information that might be useful to find 
  * the posted key names and their values of the 
  * elements in the posted form.
  */
  //print_r($_POST);
  //print_r($fields);
  //print_r($entry);
  //print_r($form_data);
  //print_r($entry_id);

  /**
  * Your Leadtrekker createlead code should follow this comment.
  * Please refer to the Getting Started section in the documentation for more information
  * on creating leads.
  * @see https://docs.leadtrekker.com
  */
}

Gravity Forms

The following is an example hook when using the Wordpress Gravity Forms plugin.


add_action('gform_after_submission', 'wp_leadtrekker', 10, 2);

function wp_leadtrekker($entry, $form)
{
  /**
  * Uncomment some of the lines below to see more 
  * debugging information that might be useful to find 
  * the posted key names and their values of the 
  * elements in the posted form.
  */
  //print_r($_POST);  
  //print_r($entry);
  //print_r($form);  

  /**
  * Your Leadtrekker createlead code should follow this comment.
  * Please refer to the Getting Started section in the documentation for more information
  * on creating leads.
  * @see https://docs.leadtrekker.com
  */
}

Ninja Forms

The following is an example hook when using the Wordpress Ninja Forms plugin.


add_action('ninja_forms_submission_actions', 'wp_leadtrekker', 10, 1);

function wp_leadtrekker($form_data)
{
  /**
  * Uncomment some of the lines below to see more 
  * debugging information that might be useful to find 
  * the posted key names and their values of the 
  * elements in the posted form.
  */
  //print_r($_POST);    
  //print_r($form_data);  

  /**
  * Your Leadtrekker createlead code should follow this comment.
  * Please refer to the Getting Started section in the documentation for more information
  * on creating leads.
  * @see https://docs.leadtrekker.com
  */
}