How to integrate Gravity Forms with Sendy

    Sendy is a self hosted newsletter application that enables you to send newsletters to your subscribers using Amazon SES, at a very low price.

    In this article we are going to explain how to integrate Gravity Forms with Sendy using a simple function.

    The function will automatically subscribe the email address submitted in the form to the Sendy newsletter list of your choice.

    For this we are going to use the post_to_third_party function after form submission from Gravity Forms API.

    First we will add an action that will tell the form what to do

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

    If you have multiple forms but want to integrate only one form with Sendy, the code needs to be changed

    add_action('gform_after_submission_1', 'post_to_third_party', 10, 2);
    

    where 1 is the ID of the form you want to integrate with Sendy.

    After that we create our function

    function post_to_third_party($entry, $form) {
    
        $post_url = 'http://your_sendy_url/subscribe';
        $body = array(
            'email' => $entry['2'],
            'list' => 'your_list_ID'
            );
    
        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));
    
    }
    

    Now you just need to change the line for your sendy list url

    $post_url = 'http://your_sendy_url/subscribe';
    

    and the line that specifies the list ID where the user will be subscribed. You can find the list ID in Sendy, by viewing all your lists, the ID will be in the right of the list.

    'list' => 'your_list_ID'
    

    Below you can copy the whole function and paste it in your theme’s functions.php file.

    add_action('gform_after_submission', 'post_to_third_party', 10, 2);
    function post_to_third_party($entry, $form) {
    
        $post_url = 'http://your_sendy_url/subscribe';
        $body = array(
            'email' => $entry['2'],
            'list' => 'your_list_ID'
            );
    
        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));
    
    }
    

    Note that the above function will subscribe form submitters to Sendy automatically, so for this reason we suggest to enable Double Opt-In in your Sendy list to give the subscriber the option to confirm the subscription.

    2 comments

    1. Tim Griffin says:

      Say – this is a very handy option for integrating Sendy and GravityForms! Thanks for posting this here.
      I have a couple questions – which I think the answers might be more or less obvious.

      a) does the array ’email’ => $entry[‘2′] indicate the field number of the form? If so, this might be different on specific gravity forms?

      b) if I want to push other details such as name, birthday etc., I’ll need to add more fields to that array. For example:
      `’email’ => $entry[‘1′],`
      `’name’ => $entry[‘2’],`

      Would allow both email and name (numbers indicate GravityForm field numbers) to be added to the designated list.

      Have you come across any good plugins to help with this important integration option?
      Keep on keeping on.

      • Edy says:

        Hi Tim,

        a) sure, the digit stands the field ID of the form. On a standard form that’s the ID of the email.

        b) by making sure the field name matches the one in Sendy, you could export any fields from a Gravity Form.

        I think I have seen a couple of commercial plugins, maybe a google search would help you.

        Thanks,
        Edy

    Leave a Reply

    Your email address will not be published. Required fields are marked *

     

Shopping Cart

  • Your cart is empty.

Get notified of new themes

Promotions

Get all our current and future themes with a one time payment.
View Details