PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamically call a different gravity form based on custom field in a post

  1. Hi GF

    I have a particular case where I need to assign a different Gravity Form to each post in a Wordpress query. We have added an "id" custom field to the backend which references the gravity form id.

    What we need now is way to (via php code) call that gravity from but replace the form id with the custom field value.

    This is the code we have tried:

    <?php $formid = the_field('bid_form_id');
    gravity_form($formid, false, false, false, '', false, 12); ?>

    However we are receiving an invalid argument error.

    Is this possible and if so, how would be go about implementing it?

    Posted 11 years ago on Monday February 25, 2013 | Permalink
  2. Can you echo $formid before you try to embed the form to see what it contains and be sure it contains the correct integer for your form ID?

    I've not see the WordPress function "the_field". Do you have documentation for that or if that's a function you wrote, please share the code.

    Posted 11 years ago on Tuesday February 26, 2013 | Permalink
  3. When I echo out the $formid - I get the correct value of the form ie. 12.

    I am using the advanced custom fields plugin to generate the custom fields. The method for calling these fields is to use "the_field('field_name')

    Posted 11 years ago on Tuesday February 26, 2013 | Permalink
  4. Got it. Thanks for that additional information. What is the actual error you are receiving (the full message please) and also, where are you using this PHP code?

    Posted 11 years ago on Tuesday February 26, 2013 | Permalink