Skip Navigation

[Resuelto] CRED Hooks

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 1 año, 2 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 5 respuestas, has 2 mensajes.

Last updated by julieP hace 1 año, 2 meses.

Assisted by: Christopher Amirian.

Autor
Mensajes
#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

Languages: Inglés (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

Languages: Inglés (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

.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.