The customer asked how the 'wpt_field_options' filter can be used to dynamically generate a long and alphabetically ordered list of options for a select type field.
Solution:
Shared some details and a code snippet example to show how this filter can be used to generate options from a custom post type:
add_filter( 'wpt_field_options', 'func_to_dynamically_populate_shop_locations', 10, 3);
function func_to_dynamically_populate_shop_locations( $options, $title, $type ){
switch( $title ){
case 'Book Shop Locations':
$options = array();
// add first empty value
$options[] = array('#value' => '', '#title' => '---');
// get all tmna-location post items
$args = array( 'post_type' => 'shop-location', 'posts_per_page' => -1, 'post_status' => 'publish','orderby' => 'title' );
$results = get_posts( $args );
if ( $results ) {
foreach ( $results as $post ) {
$options[] = array('#value' => $post->ID, '#title' => $post->post_title);
}
}
break;
}
return $options;
}
Problem:
Set post author dynamically as current loggedin user when you submit the toolset form and generate post title
Solution:
You can use the Toolset Form's hook "cred_save_data" to set the post author and generate the post title dynamically after you submit the form.
Solution:
Toolset follows the WordPress standards and it does stores the custom fields values you created using Toolset Types plugin to the postmeta table.