I'm using:
global $wpdb;
$result = $wpdb->get_results("SHOW TABLE STATUS LIKE 'wp_rg_lead';");
$entryId = $result[0]->Auto_increment;
Is there a better way to get the entry ID before its generated?
I'm using:
global $wpdb;
$result = $wpdb->get_results("SHOW TABLE STATUS LIKE 'wp_rg_lead';");
$entryId = $result[0]->Auto_increment;
Is there a better way to get the entry ID before its generated?
I don't know a good way to get the auto generated IDs before the record is created. The safe way to do this is to first create the record and then use $wpdb->insert_id to read the ID that was created.
If you describe a little more what exactly you are trying to do, I may be able to help you with some alternatives.
I need to attach a reference number (entry ID) to a UPS label which is generated on gform_pre_submission_filter (before entry ID is generated) so that I can save the tracking number to a hidden field.
The method in my initial post works, I just wanted to see if there was an official GF API call that did the same thing.
I see what you are trying to do, but I think this method is not 100% reliable. If two entries get submitted around the same time, you might end up using the wrong entry id. The chances of that happening are probably not very high, but it could happen. If you decide to do it this way, I would change the query to
SHOW TABLE STATUS WHERE name='wp_rg_lead'
If you don't want to take that chance, use the gform_after_submission hook instead, where you have access to the entry id, then manually change the value of your hidden field using a sql statement:
$wpdb->query("UPDATE wp_rg_lead_detail SET value='TRACKING_NUMBER' WHERE lead_id=ENTRY_ID AND field_number=HIDDEN_FIELD_ID")
I need to reference the entry id in a newly created form field when a new entry is created. Perhaps pre-lead the entry id with the letters "CT". How can I make this happen? I'm not a programmer, but I follow instructions quite well.
@italianbird, can you explain your scenario in a little more detail so we can help you with detailed instructions? Thank you.
I've created an additional form field called 'Internal Pro Nbr'. I'd like that field to be populated by the entry number that is already assigned to each new form submission or record. These numbers start with 1 thru infinity and indicated on each new record.
What we'd additionally like to do is throw in pre-leading characters such as CT00(entry id#).