WordPress Gravity Form – Microsoft CRM Integration - CloudFronts

WordPress Gravity Form – Microsoft CRM Integration

This blog is about integration of Gravity Form plugin with the Microsoft Dynamics CRM. This part contains the WordPress end implementation.

Gravity Forms is an advanced contact form plugin for WordPress powered websites and is used by millions of sites. Gravity form simply allows you to select your fields, configure your options and easily embed forms on your site using the built-in tools.

We will implement Gravity form on website so that the values submitted in it will directly go to CRM as lead.


  1. Firstly, install the Gravity form, which you can purchase depending on your requirement. [Link : http://www.gravityforms.com/purchase-gravity-forms/]
  2. Set up your fields as per your requirement and note the field ID. Also call the form wherever you want to use (page editor or php template or widget).
  3. gravity-form

  4. Now, you have to use the Gravity Form’s gform_after_submission function along with the field ID’s to pass the parameters.
  5. Once you are done with the form implementation, next step is to write code for passing the parameters in functions.php file of current theme.
    add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 );
    function post_to_third_party( $entry, $form ) {   
        $post_url = 'http://thirdparty.com';
        $body = array(
            'first_name' => rgar( $entry, '1.3' ), 
            'last_name' => rgar( $entry, '1.6' ), 
            'message' => rgar( $entry, '3' ),
        $request = new WP_Http();
        $response = $request->post( $post_url, array( 'body' => $body ) );    

    post_url = URL of the page where your web service is written/called.

    first_name (or last_name or message) = Name of parameters used in web service where values will be stored. You can create any number of fields and pass their values.

    ($entry, ‘3’) = Here 3 is the id of the field in gravity form, whose value will be passed in the ‘message’ parameter. For name, we have two ID’s as it has first name and second name fields.

    gform_after_submission = Function executed at the end of the form submission process (after form validation, notification, and entry creation). If you want to implement this for any particular form, then you can use “gform_after_submission_FORM-ID” like gform_after_submission_2.

  6. Now the values of the fields filled in Gravity Form will be passed to web service and then it will be stored as Lead in CRM. We recommend you to use captcha with form to avoid spam entries in CRM.



Share Story :