contact form 7 – fill form with template vars

I’m loading the form with the following example:

<?php echo do_shortcode('[contact-form-7 id="49" title="Test"'); ?>

Now I would like to pass some variables to (pre) fill the form directly, e.g. like this:

Read More
<?php echo do_shortcode('[contact-form-7 id="49" title="Test" city="' . $city . '"'); ?>

Any ideas how to achieve this properly? I’ve thought about to explode the form string, search the desired input field and fill it but I think this is not very efficient.

Related posts

Leave a Reply