[Resuelto] Use wpt_field_options only in a Specific form
This support ticket is created hace 3 años, 7 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 – 12:00
9:00 – 12:00
9:00 – 12:00
9:00 – 12:00
9:00 – 12:00
-
-
13:00 – 18:00
13:00 – 18:00
13:00 – 18:00
14:00 – 18:00
13:00 – 18:00
-
Supporter timezone: America/Jamaica (GMT-05:00)
Este tema contiene 2 respuestas, tiene 2 mensajes.
Tell us what you are trying to do?
I need translate de options of select in a Specific form and i wish know if can use wpt_field_options only in that form and dont affect others forms.
Is there any documentation that you are following?
I read the api of that command and not saw if can limit her use.
Is there a similar example that we can see?
I use that example but affect to all forms, i tried put a if saying if form X but not see that work
Thank you for getting in touch. As this hook is meant to be used with Types fields there isn't any integration on it to check for a specific form ID, instead it will only modify the field that it is meant to target.
So you aren't able to apply this hook to only a specific form. If you take a look below you will see the context under which the hook is meant to be used and the parameters that it accepts.
My issue is resolved now. Thank you! the post id dont work because only get the id of new post that going to make ,no the id of form or page where that select are working.
add_filter( 'wpt_field_options', 'tssupp_populate_user_field_a', 10, 2 );
function tssupp_populate_user_field_a( $current_options, $title_of_field ){
//field name
if ( 'Diagnóstico' == $title_of_field ) {
//page where the form load
if ($_SERVER['REQUEST_URI']== "/adicionar-paciente/")
{
$current_options = array();
//añadimos al select, usuarios que solo sean del rol laboratorios
$users = get_users(array( 'role' => 'laboratorios' ));
foreach ($users as $user) {
$current_options[] = array(
'#value' => $user->ID,
'#title' => $user->user_login,
);
}
}
return $current_options;
}