Hi, I use a Cred Form to update custom fields of a CPT.
Before the Form is submitted (and the CPT is updated) I would need to do some operation with the new values entered into the Cred fields.
How do I read these values if the form haven't been submitted yet?
Thanks
Best
Hello, two Forms API hooks are triggered before the post is updated:
cred_before_save_data - https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data
cred_form_validate - https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
Normally you would use cred_before_save_data if you do not want to block the Form submission process. You should use cred_form_validate if you may want to block Form submission and display errors in the Form based on custom code criteria.
For example, let's say you want to verify the User has submitted a unique value for some custom field. If the value is not unique, you want to block the Form submission process. You must use cred_form_validate in this case to perform a post query based on that custom field value. If the value already exists, you can show an error in the Form and the post submission will be blocked until the User submits a unique custom field value. On the other hand, let's say you want to copy a custom field value into a related post. The hook cred_before_save_data should be used to perform automatic actions that do not impact the post submission process.
Let me know if you have questions about implementing either of these APIs.