Skip Navigation

[Resuelto] set value in a CRED field

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

Problem:
How to set value in a CRED field

Solution:

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/set-value-in-a-cred-field/#post-841202

Relevant Documentation:

This support ticket is created hace 6 años, 6 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Minesh hace 6 años, 6 meses.

Asistido por: Minesh.

Autor
Mensajes
#840401

Hello, I explain my problem:

I have this input form:

[credform class='cred-form cred-keep-original']
<div class="form-group">
<label>Universidad Popular que contrata</label>
[cred_field field='_wpcf_belongs_universidad-popular_id' value='[id_univ_usuario]' required='true' class='form-control' output='bootstrap']
</div>
[/credform]

I want to auto select the field. The shortcode [id_univ_usuario] return the ID of the custom field that I want to auto select, but the field display "not-select".

My shortcode code is:

// Get 'CPT Universidad Popular' ID of the user login.
function jm_id_univ_usuario(){
global $current_user;
$args = array(
'post_type' => 'universidad-popular',
'author' => $current_user->ID,
'status' => 'publish',
);
$id_universidad = get_posts( $args );
echo $id_universidad[0]->ID;
}
add_shortcode ('id_univ_usuario', 'jm_id_univ_usuario');

Thanks.

#841202

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you are echoing the ID from your shortcode. Instead of echoing, you should return the id.

Could you please try following code:

[credform class='cred-form cred-keep-original']
<div class="form-group">
<label>Universidad Popular que contrata</label>
[cred_field field='_wpcf_belongs_universidad-popular_id' value='[id_univ_usuario]' required='true' class='form-control' output='bootstrap'  use_select2="never" ]
</div>
[/credform]

Where:
- we set the shortcode to not to use select2.

Instead of echo - return the Id.

// Get 'CPT Universidad Popular' ID of the user login.
function jm_id_univ_usuario(){
global $current_user;
$args = array(
'post_type' => 'universidad-popular',
'author' => $current_user->ID,
'status' => 'publish',
);
$id_universidad = get_posts( $args );
return $id_universidad[0]->ID;
}
add_shortcode ('id_univ_usuario', 'jm_id_univ_usuario');