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;
}