Skip Navigation

[Resuelto] Display parents of current user in a select

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

Problem:
Client uses custom code to modify the list of parent posts in a child CRED form select box so that it only includes parents authored by the current user, but the code has stopped working.

The problem occurs because when there are more than 15 possible parents to display the select2 library is invoked on the select field to manage the long list of options, and this breaks the custom code.

Solution:
Disable select2 on the parent selector field by adding the attribute use_select2="never" to the cred_field shortcode.

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

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Etiquetado: 

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por rafaelE-3 hace 6 años, 9 meses.

Asistido por: Nigel.

Autor
Mensajes
#618412
Descuento_para_reserva_por_casa_completa___Asociación_Casas_Rurales_Amigas.jpg

I need to show in a child form select, the parents created by a user.
I was following this tutorial:
https://toolset.com/forums/topic/i-want-to-only-display-the-parent-items-of-the-current-user-in-a-select-box-2/
It works perfect one week ago, but now it's showing all parents and I don't know why.

This is my code at the form:
"
This is only for test display: [get-parents]
<label>¿A qué casa pertenece esta oferta?</label>
<input type="hidden" id="parents_id" value="" />
[cred_field field='_wpcf_belongs_casa-rural_id' value=''order='title' ordering='desc' required='true' select_text='--- ---' validate_text='Debes seleccionar una casa rural' class='form-control' output='bootstrap']

If you see the Screenshot, the [get-parents] function it's working, but the select it's showing all the parents and not just the author parents.

Can you help me?
Thanks in advance!

#618601

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi Rafael

I suspect the reason this was working and stopped working a week ago is because you have added more parent posts. CRED now uses a JS library select2 for select fields that asks you to enter the first couple of letters of the parent post to avoid showing very long lists of options when there are more than around 15 parent posts. This will have broken the code you are using.

You can disable select2 on the field so that it works again by editing your CRED form, and for the cred_field shortcode that adds the parent selector, include the attribute use_select2="never" in the shortcode.

#618730

Thank you very much, Nigel! It solved the issue! 😀