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.

Get a form id from title

  1. jezza73
    Member

    Hi,

    I am using the php method of embedding forms. I have a template which I want to use to embed a form by using the page title to look up a form id by matching it to a form title.

    As an example, if a wordpress page has the title "page one" I want to embed the form which has a title of "page one" but I can only do this by getting the form's id number. If I can match the wordpress page title to the form's title I should then be able to get its id number.

    Any ideas how I can do this?

    Thanks,

    Posted 12 years ago on Friday November 25, 2011 | Permalink
  2. You can use this Gravity Forms function:

    [php]
    $form_id = RGFormsModel::get_form_id($post->post_title);

    That will take the post title of the current post (assuming the $post object is storing it) and find the ID of a form with that exact title. Then you can use $form_id in your gravity_form function call, like this:

    [php]
    <?php gravity_form($form_id, false, false, false, '', false); ?>

    You will need to handle any sort of error if no form is found or if there are case differences, but this function will return the form ID based on the form title. In your case, the Page title will be the same, which is why you can use that.

    Posted 12 years ago on Friday December 2, 2011 | Permalink
  3. jezza73
    Member

    Thank you very much!

    Posted 12 years ago on Monday December 5, 2011 | Permalink
  4. Great - I learned something new in the process there :-)

    Posted 12 years ago on Monday December 5, 2011 | Permalink

This topic has been resolved and has been closed to new replies.