hi all,
Ive read from this post
http://www.gravityhelp.com/forums/topic/guid-entry-id
and i made an updated code for generating Incremental ID generation
<?php
add_filter("gform_pre_render", "process_unique");
function process_unique($form) {
global $uuid;
$uuid['form_id'] = $form['id'];
switch($form['id']) {
case 6: //form ID
$uuid['field_id'] = 60; //field ID on the form
break;
case 14: //form ID
$uuid['field_id'] = 158; //field ID on the form
break;
case 12: //form ID
$uuid['field_id'] = 158; //field ID on the form
break;
case 11: //form ID
$uuid['field_id'] = 34; //field ID on the form
break;
}
add_filter("gform_field_value_uuid", "get_unique");
return $form;
}
function get_unique(){
global $uuid;
$form_id = $uuid['form_id'];
$field_id = $uuid['field_id'];
switch($form['id']) {
case 6:
$prefix = "FOHSRF # - "; //prefix for different forms
break;
case 14:
$prefix = "VSRF # - "; //prefix for different forms
break;
case 12:
$prefix = "VSRF # - "; //prefix for different forms
break;
case 11:
$prefix = "VSDEIF # - "; //prefix for different forms
break;
}
do {
$formid = $form_id; //get ID of the form
$form_count = RGFormsModel::get_form_counts($formid);
$unique = $form_count['total'] + 1; // count of the lead form entries incremented by one
$unique = str_pad($unique, 3, '0', STR_PAD_LEFT); // padding for number format 001,002...015 so 3 digit number format
$unique = $prefix . $unique; // prefix and the unique number
} while (!check_unique($unique, $form_id, $field_id));
return $unique;
}
function check_unique($unique, $form_id, $field_id) {
global $wpdb;
$table = $wpdb->prefix . 'rg_lead_detail';
$result = $wpdb->get_var("SELECT value FROM $table WHERE form_id = '$form_id' AND field_number = '$field_id' AND value = '$unique'");
if(empty($result))
return true;
return false;
}
?>
hope this helps.
cheers,