Skip Navigation

[Resolved] Regular price field with default value which the user cannot change

This support ticket is created 2 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

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 1 reply, has 2 voices.

Last updated by Minesh 2 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#2410523

I use the Front End Product Submission form. One of the items is the Regular price field. I want to set a default value which the user cannot change.
Do you have a suggstion for this.
Thx for clarifying.

Regards
Loek

#2410769

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

There are couple of ways, to set regular price either you can add it as hidden field and set it's default value or you can use the Toolset Form's hook "cred_save_data" that will run after you submit the form.

For example - you should try to add the following code to "Custom Code" section offered by Toolset:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

function func_custom_update_product_regular_price($post_id, $form_data) {
    // if a specific form
    if ($form_data['id']==99999) {
            update_post_meta($post_id,'_regular_price', 1111);
    }
}
add_action('cred_save_data', 'func_custom_update_product_regular_price', 10, 2);

Where:
- Change the 99999 with your original form ID
- change 1111 with the actual regular price you want to set.