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.

Use gform_after_submission to update an entry

  1. MFJUNIOR
    Member

    Hi,

    I'm using gform_after_submission to populate a table in database after a person submit a form:

    add_action("gform_after_submission_5", "input_fields", 10, 2);
    function input_fields($entry, $form){
        global $wpdb;
    		$id = $entry['id'];
    		$date = $entry['date_created'];
    		$title = $entry['1'];
    		$firstname = $entry['2.3'];
    		$lasname = $entry['2.6'];
    $SQL = "INSERT INTO abstracts ( abstract_id, date, firstname, lasname ) VALUES ( '$id', '$date', '$firstname',  '$lasname' )";
     $wpdb->query($SQL);
    }

    I also using a plugin Admin&Single Gravity Forms Add-On that simulate a post and let the users to edit their entry with a given link (/.../form/?rid=1).

    When someone submit the modified form, the entries are updated in the gravity forms database, but the gform_after_submission doesn't update the other database.

    I think will be the same if I edit the entry by the admin side.

    How is possible to update the entry also in the second database?

    Than you, Marco

    Posted 11 years ago on Tuesday February 12, 2013 | Permalink
  2. gform_after_submission will work only after a Gravity Form is submitted. If you edit the entry in the Gravity Forms admin, you can use the gform_after_update_entry to update your external database.

    http://www.gravityhelp.com/documentation/page/Gform_after_update_entry

    I'm not familiar with that Admin & Single plugin to know how it works, but if it does not submit a Gravity Form, gform_after_submission will not work. You will need to find a hook in that plugin to run your code when an entry is edited like that from the front end.

    Posted 11 years ago on Wednesday February 13, 2013 | Permalink
  3. I am looking to do something similar but gform_after_update_entry returns an entry_id rather than the entire entry like gform_after_submission does. Is there something to retrieve the full entry from the entry_id? I've looked through the documentation but don't see anything like that.

    Posted 11 years ago on Monday March 4, 2013 | Permalink
  4. @DMU, please let us know what you are trying to do and we will try to help.

    Posted 11 years ago on Tuesday March 5, 2013 | Permalink
  5. I used gform_after_submission to send the entry information to another system of ours. If I update that entry in WordPress I want it to update that entry information in this other system, however gform_after_update_entry doesn't supply the entry information, just the ID.

    Posted 11 years ago on Thursday March 7, 2013 | Permalink
  6. I see. In the code you run which is hooked to gform_after_update_entry, you can get the full entry details like this, using the entry (lead) ID:

    [php]
    $lead = RGFormsModel::get_lead($lead_id);
    // debug
    // print_r($lead);
    Posted 11 years ago on Tuesday March 12, 2013 | Permalink