Hi,
Welcome to Toolset support and I'd be happy to assist.
I'm afraid, there is no built-in feature, that can be used to define a new type of custom field, but you can use the "wpt_field_options" filter to dynamically add options to a "select" type custom field.
( ref: https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options )
For example, suppose that you have a "Books" post type and you need a "Book User" custom field for it, which should consist of dropdown options for all the "subscriber" role users.
In the custom field group for this Books post, you'll add a new "select" type custom field "Book User", which will only have a default option with an empty value.
( as shown in the attached screenshot )
Next, you can add a custom function linked to "wpt_field_options" filter, which can dynamically insert more options for all the "subscriber" role users, into this "Book User" field, using the "get_users" function.
( ref: https://developer.wordpress.org/reference/functions/get_users/ )
Example:
add_filter( 'wpt_field_options', 'add_user_options_func', 10, 3);
function add_user_options_func( $options, $title, $type )
{
switch( $title )
{
case 'Book User':
$args = array(
'orderby' => 'display_name',
'fields' => array( 'ID', 'display_name'),
'role' => 'subscriber'
);
foreach( get_users($args) as $user ) {
$options[] = array(
'#value' => $user->ID,
'#title' => $user->display_name,
);
}
break;
}
return $options;
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.
I hope this helps and the custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar