Skip Navigation

[Resolved] I need to make an auto unique number for each new form submitted from front-end

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 8 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2690816

Tell us what you are trying to do?
I've created a Post type named "Job Order", where the users can submit new job order by a form at the front-end, then they can display the Job Order in View loop and Template.

I'm trying to do:
First:
An auto incremental unique number ex; 101, 102,103.. etc. for each submitted Job Order, As an ID..
Second:
I want to display this unique number (or ID) in the View loop and Template.

If it possible also, do searching by this ID.
--------------------------------------------------------------------------
Another different thing:
I would like to print the Job Order after submitted as it is designed in the template in (Arabic Language), any suggestion?
--------------------------------------------------------------------------
NOTE: I'm not good enough with coding!.
My greeting;
Thank you.

What is the link to your site?
hidden link

#2690853

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

If you want to search for the unique number then you will have to add a custom field Unique ID and store the unique ID on form submit using the Toolset Form hook "cred_save_data":
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

Assuming you have created a custom field "Order ID" and slug of this field is "order-id":

You can add the following Toolset form hook to "Custom Code" section offer by Toolset:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset

add_action('cred_save_data', 'func_set_post_id_as_unique_id',10,2);
function func_set_post_id_as_unique_id($post_id, $form_data) {
       
    if ($form_data['id']==99999){
       
       $field_slug = 'order-id';
        update_post_meta($post_id,'wpcf-'.$field_slug , $post_id);
    }
}

Where:
- Replace 99999 with your original Form ID.

Technically every post ID is unique so the above code will help you to set post ID as order ID and later you can use the custom field order id to search as well.

#2691133

Thank you so much, I will try to do this.

What about Printing the page of Order submissions as it is design in a Template?

#2691355

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

We do not offer any dedicated print feature. You can check with any other available options.