Skip Navigation

[Résolu] CRED Hooks

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:

How can I retrieve taxonomy from customer-entered form content?

Solution:

var_dump the $_POST array to see the proper key values that you have in before_save_data hook.

<pre>
<?php var_dump($_POST); ?>
</pre>
<p>

This support ticket is created Il y a 1 année et 10 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par julieP Il y a 1 année et 9 mois.

Assisté par: Christopher Amirian.

Auteur
Publications
#2547763

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?

#2548293

Christopher Amirian
Supporter

Les langues: Anglais (English )

Hi there,

Toolset adds the taxonomies using the standard WordPress development method. So using the same standards you can retrieve the taxonomies:

https://developer.wordpress.org/reference/functions/get_taxonomy/

Or you can use the method below which is a Toolset shortcode:

https://toolset.com/forums/topic/how-to-display-custom-taxonomy-directly-in-php-file/#post-409140

For more information:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-taxonomy

Thanks.

#2548511

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?

#2549581

Christopher Amirian
Supporter

Les langues: Anglais (English )

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.

#2550147

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"

#2550149

.