First of all, make sure that the bdp_id is available in the Contact Form 7 (CF7) definition as a hidden field:

bdp_id_-_In_CF7_form_as_hidden_field

This CF7 tag copies a bdp_id attribute from the CF7 shortcode into the form data.

So the next step is to add the bdp_id attribute to the CF7 shortcode where the form is added to the page [contact-form-7 id=”1899″ bdp_id=””]

Your form id will, obviously, be different. Next, we will find and insert the value for the bdp property id. This contact form may be anywhere on the site, but one useful location would be within the property details page. In which case, we now need to add this to our PropertyHive template content-single-property.php

The BDP for PropertyHive plugin provides a convenience method to get the BDP property id inside this template, or wherever a property is referenced, so we can just call $bdpid = $property->get_bdp_id(); to retrieve the relevant value for the form setup.

Let’s add that BDP property id to the CF7 tag, inside the bdp_id attribute.

To ensure that the CF7 shortcode is properly processed in the PropertyHive template, we should also wrap it in a call to do_shortcode, to make sure that WordPress properly expands all shortcodes.

The end result is that the following code will generate the correct form and meta data you need, and insert it into the html of the page.

      <?php
      $bdpid = $property->get_bdp_id();
      echo do_shortcode('[contact-form-7 id="1899" bdp_id="' . $bdpid . '"]');