I have edit project form where project is the CPT and has a taxonomy called skills.
The edit form has lot of edits including the taxonomy field.
I want to have no custom effect if the taxonomy fields are not changed.
But, if the taxonomy fields are updated in the edit form, I want to trigger some custom code by using cred_save_data.
Now, my understanding is that at cred_save_data, the field is already changed so I won't have the original data available.
Which hook can I use to compare the current taxonomy and new taxonomy to trigger different code if there is an edit.
A few questions
1. Is it cred_before_save_data?
2. If yes, how do I get the post ID to get the original data and how to do I get the newly selected data. Is it using $_POST['my_custom_field'] format?
3. What happens if it is a multi select taxonomy? How do I get value for all selected fields?
Hello,
1) Yes, you can try with cred_before_save_data action hook.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data
This hook allows doing a custom action right before saving or processing any data but after validation
2) Yes, you can get the post ID by variable $_POST['_cred_cred_prefix_post_id'], and use it to get other information of original post.
3) You can get the new user input values, for example WordPress Built-in category:
$_POST['category']
My issue is resolved now. Thank you!