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, 9 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Este tema contiene 5 respuestas, tiene 2 mensajes.

Última actualización por julieP hace 1 año, 9 meses.

Asistido por: 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

Idiomas: 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

Idiomas: 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

.