I know I can capture a custom field value before it's actually saved using $_POST['wpcf-custom-field']['value'] in the before_save_data hook but how would I do the same for taxonomy please?
Data is not displayed in CRED hooks, it's retrieved.
Please revisit my question; how do I retrieve (define to a variable) the values of a taxonomy field on a CRED form in the before_save_data hook?
Hi there,
If there is an option to select the taxonomy you only have the $_POST to access whatever data the customer selects. To see a list of available options you can add the code below:
<pre>
<?php var_dump($_POST); ?>
</pre>
That way you will be able to see what are the results of the array of $_POST and see which item suits your needs.
If you need the taxonomies of the post in question you can use the method below which is a native WordPress code:
https://wordpress.stackexchange.com/questions/162175/get-taxonomy-names-by-post-id
If you give me more context on how you set your form and which options are there I might be able to understand the request better.
Thanks.
I really don't know what is clearer than "how do I retrieve (define to a variable) the values of a taxonomy field on a CRED form in the before_save_data hook"