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.

gform_update_meta doesn't work as expected

  1. Scenario: User inputs Social Security Number via form. Using gform_post_submission hook, I am trying to encrypt the entry's SSN (which is $entry['5']).

    Code (most of the beef has been removed):

    #####################################
    function encryptStringArray($stringArray, $entryID, $key = "somecoolkey") {
    	$s = DOSOMEENCRYPTIONHERE($stringArray, $key);
    	gform_update_meta($entryID, $entry['5'], $s);
    	return $s;
    }
    
    add_action("gform_post_submission", "hNotify", 10, 2);
    function hNotify($entry, $form){
      $entryID = $entry["id"];
      $ssn = encryptStringArray($entry["5"], $entry);
    }

    Based on the [ever-lacking] documentation, it appears like I should use this function: gform_update_meta

    However, the examples: #1 SUCK (in explanation, implementation, and as an example... fail), #2 don't work (the entry goes through, PHP error prevents full functionalities).

    So can anyone please shed some light on how one goes about updating an entry after it has been pushed to the database?

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

    Posted 12 years ago on Thursday September 8, 2011 | Permalink
  2. craigedmonds
    Member

    why dont you use the wordpress update_post_meta?

    I have just done it using gform_post_submission.

    You grab the form fields from the array and then use update_post_meta($newpostid, 'fieldname', $thedata);

    Posted 12 years ago on Thursday September 8, 2011 | Permalink
  3. I am trying to update the actual entry, not a post or page.

    Posted 12 years ago on Thursday September 8, 2011 | Permalink
  4. Looks like I need to be using: gform_save_field_value / gform_get_field_value

    Posted 12 years ago on Thursday September 8, 2011 | Permalink
  5. Yes that is correct, you would need to use those 2 hooks to encrypt and decrypt the field values.

    Posted 12 years ago on Thursday September 8, 2011 | Permalink

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