Advertisement
chrishajer

Update entry with a reference number including $entry['id']

Nov 11th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // more complete version of updating an entry with the entry ID as part of a reference number
  3. // after the form was submitted
  4. // change the 19 here to your form ID
  5. add_action("gform_after_submission_19", "set_reference_number", 10, 2);
  6. function set_reference_number($entry, $form){
  7.  
  8.     global $wpdb;
  9.     // which field do you want to add the reference number to?  Change 18 here to your field ID
  10.     $field_number = 18;
  11.     // this is the format for the reference number to store
  12.     $reference = 'VSR-' . $entry['id'];     // change this to whatever you want to store
  13.     $wpdb->insert("{$wpdb->prefix}rg_lead_detail", array(
  14.         'value' => $reference,
  15.         'field_number' => $field_number,
  16.         'lead_id' => $entry['id'],
  17.         'form_id' => $entry['form_id']
  18.     ));
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement