PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

SMS API Gateway - Need help to get GForm to integrate

  1. Hi Guys.. have tried studying other posts but this is nails!

    I have an account with a text message service http://www.txtlocal.co.uk/developers/code/

    To connect to the API, you can POST or GET your query to the URL:
    http://www.txtlocal.com/sendsmspost.php

    Ive read through some of the Hook posts and guess i need to add to the functions.php file but struggling to put the code together. They provide codes to use but cant work out how they combine . An example is;
    This example uses the cURL library, please ensure it is enabled on your server.

    http://pastie.org/1621945

    Any ideas? Real sorry to ask as i know its on here somewhere!

    Jamie

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  2. You would use the gform_post_submission hook to do this, which has access to the entry data from the entry that is created. I can give you an example of how to use the gform_post_submission hook but I can't write the code to integrate with the 3rd party service. That is much too involved for a standard support request.

    Have you considered paying a WordPress consultant to do this customization for you? I can recommend a WordPRess consultant with Gravity Forms development/customization experience who could assist you with this code if you wanted to go down that route. You could at least get a quote from them on how much it would cost for the integration.

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  3. Hi Carl.. Yeah - sure thing bud... was thinking it might be a bit too much to do myself!

    If you can give me a nudge in the right direction regarding the hook i will have a look.

    Worst case If you have details of someone i could speak to also that would be great as these things can take weeks off your life hey!.

    Jamie

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  4. You would want to use the gform_post_submission hook which has access to the Entry object. The Entry object all data from a submitted form.

    You can use the gform_post_submission 2 different ways.

    If you want to apply the code to ALL forms you would use it this way:

    <?php
    add_action("gform_post_submission", "post_submission", 10, 2);
    ?>

    If you want to apply the code to a SPECIFIC form you would use it this way, this example would target form id 5:

    <?php
    add_action("gform_post_submission_5", "post_submission", 10, 2);
    ?>

    Here is an example of the gform_post_submission in action, this example uses the gform_post_submission hook to change the post content, adding values from submitted fields, including an image field. It doesn't do what you want it to do, it's purely an example of the gform_post_submission usage:

    <?php
    add_action("gform_post_submission", "set_post_content", 10, 2);
    function set_post_content($entry, $form){
    
    //getting post
    $post = get_post($entry["post_id"]);
    
    //changing post content
    $post->post_content = "Blender Version:" . $entry[7] . "<br/> <img src='" . $entry[8] . "'> <br/> <br/> " . $entry[13] . " <br/> <img src='" . $entry[5] . "'>";
    
    //updating post
    wp_update_post($post);
    }
    ?>

    The gform_post_submission hook has access to the Entry object. Here are examples:

    $entry["date_created"];   //returns the entry date
    $entry["1"];              //returns the value associated with field 1
    $entry["2.4"];            //returns the value associated with the street input for the address field 2

    So you would use the field id OR keywords for default data associated with the entry. These keywords are:

    - id
    - date_created
    - is_starred
    - is_read
    - ip
    - source_url
    - post_id
    - FIELD_ID

    If this is all greek to you... then hiring a WordPress consultant to do the implementation may not be a bad idea. I would recommend:

    Ounce of Talent
    http://www.ounceoftalent.com

    WebDevStudios
    http://www.webdevstudios.com

    Posted 13 years ago on Wednesday February 9, 2011 | Permalink
  5. I am implementing an API connection with a number of existing forms. I want to add a hidden field to the forms that we DON'T want to have use the API. Is there a way to call entry fields by name rather than placement?

    For instance, if I set a hidden field in position 8, to flag the API to not execute for that form, my code would look something like this:

    if ($entry["8"] != 1) {
    //DO Cool Stuff Here
    }'
    
    But that would only work as long as it's the 8th field on the form. Is it possible to reference the field name (in this example the field name would be "api_ready") (something like:
    
    'if ($entry["api_ready"] != 1) {
    //Do Cool Stuff Here
    }

    Does that make sense?

    Posted 13 years ago on Tuesday March 1, 2011 | Permalink
  6. The id is assigned to the field when you add it to your form. It doesn't change when you re-order your form so it's not really based on the placement. It's based on the order it was added to the form. Currently the field is is the only way to interact with fields when using hooks and accessing the entry object.

    Posted 13 years ago on Tuesday March 1, 2011 | Permalink
  7. Thanks Carl!

    Posted 13 years ago on Tuesday March 1, 2011 | Permalink

This topic has been resolved and has been closed to new replies.