Skip Navigation

[Resuelto] Need to get Repeating Image Field URLs in CRED Form for PHP…

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

Problem:
The customer asked how to get the image URLs from a repeating image field when the Toolset Form is submitted.

Solution:
Suggested to use the "cred_save_data" hook with a code example.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

https://toolset.com/documentation/customizing-sites-using-php/functions/#image

This support ticket is created hace 2 años, 5 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por shawnW-3 hace 2 años, 5 meses.

Asistido por: Waqar.

Autor
Mensajes
#2386765

Tell us what you are trying to do?
The long story is I need to convert images to base64 to add them as attachments to a CRM via API...

BUT my understanding is that in order to encode these images I need to first access the URLs of these images.

So something like $_POST["wpcf-problem-images-contact"] isn't going to get me what I need.

So, like the subject says, I need to access what I suspect is a value inside the field, and being a repeating field complicates that further.

Is there any documentation that you are following?
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_ajax_upload_validate

Is there a similar example that we can see?
No.

What is the link to your site?
N/A

#2387123

Hi,

To get the image URLs from a repeating image custom field, you can use the 'cred_save_data' hook, with the Types fields API function, for example:


add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==12345)
    {
        $images = types_render_field( "image-field-slug", array( "item" => $post_id, "output" => "raw", "separator" => "," ) );
    }
}

Note: You'll replace "12345" with the form's ID and the "image-field-slug" with the repeating image field's slug and you'll get the comma-separated list of image URLs in the '$images' variable.

Related documents:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/customizing-sites-using-php/functions/#image

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2389181

Sorry for the delayed response. This was EXACTLY what I was needing. Many thanks! My issue is resolved now.