[Resolved] My form updates a CPT entry, but I can't force a value into a preexisting field
This support ticket is created 8 years, 2 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I am trying to: to make the form fill a field with a new value for field "status-cover". Despite all my efforts, the form always keep the original value loaded; since it'll be a hidden field, the user cannot type the new value. I must define it.
I visited this URL: hidden link
I expected to see: in the last form field, the value should be "ongoing"
Instead, I got: the existing value, "pending-author-questionnaire"
I tried to force the default value in the shortcode:
None of the above worked. The form update only the fields altered by the user itself; if I kept the field read-only, it wont save the value I've informed, it'll rather keep the original one already stored.
Just tried, and this don't solve the problem. I need this new value to be stored, not just to be replaced in the form. Otherwise it'll be useless.
I'll explain again.
I have a custom post type called Book. I created this Cred update form, to fill some fields and store them (all of them).
But one of those fields is a status field, that starts in this form with the value "pending-author-questionnaire".
What I need this Cred form to is to change this value to "ongoing", after my client press "submit". None of the methods I tried above, and yours too, helped me accomplish this simple task.
What should I do to update this field with a different value?
Thank you what you can do is add the following to your functions.php file.
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==12)
{
// add it to saved post meta
add_post_meta($post_id, 'wpcf-status-cover', "ongoing", true);
}
}
What you need to do is change the 12 to the id of your Cred form.