I do not think that wpcf7_form_tag works the same way as vikent showed in his big answer before. Perhaps it has changed since 2015.
If you read here, this explains how you need to use wpcf7_form_tag: https://contactform7.com/2015/01/10/adding-a-custom-form-tag/
Keeping this in mind with this other post from contact form 7: https://contactform7.com/2015/02/27/using-values-from-a-form-tag/#more-13351
I came up with this code to create my own dropdown for the custom message type that I have.
add_action ('wpcf7_init', 'custom_add_form_tag_customlist');
function custom_add_form_tag_customlist() { wpcf7_add_form_tag( array( 'customlist', 'customlist*' ), 'custom_customlist_form_tag_handler', true ); } function custom_customlist_form_tag_handler( $tag ) { $tag = new WPCF7_FormTag( $tag ); if ( empty( $tag->name ) ) { return ''; } $customlist = ''; $query = new WP_Query(array( 'post_type' => 'CUSTOM POST TYPE HERE', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', )); while ($query->have_posts()) { $query->the_post(); $post_title = get_the_title(); $customlist .= sprintf( '<option value="%1$s">%2$s</option>', esc_html( $post_title ), esc_html( $post_title ) ); } wp_reset_query(); $customlist = sprintf( '<select name="%1$s" id="%2$s">%3$s</select>', $tag->name, $tag->name . '-options', $customlist ); return $customlist; }
Then you use a tag in contact form 7 like this.
[customlist your-field-name]
Hope this helps someone who was looking for a way to do this, like me.
You can change it to get the necessary information from a custom message type.
However, he has no verification.