Navigation überspringen

[Gelöst] CRED Hooks

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 1 Jahr, 10 Monaten. 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.

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von julieP vor 1 Jahr, 10 Monaten.

Assistiert von: Christopher Amirian.

Author
Artikel
#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

Sprachen: Englisch (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

Sprachen: Englisch (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

.