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.

Pre-filling field with post category?

  1. gravityfc
    Member

    Our gravity form is embedded inside all of our WP posts. Is it possible to have the category of each particular post passed automatically into a hidden field in the gravity form?

    I've tried using the "Post Fields - Category" field, but it does not seem possible to get that entry to be auto-filled. (Instead, I can only get it to allow the user to manually select a category).

    I've also tried using a "Standard Fields - Single Line Text" field with a merge tag, but I do not see an option for categories in the "Insert Merge Tag" drop down admin menu. (Only "Client IP Address" etc.)

    The goal of the above question is to then allow us to use conditional logic to display different confirmation messages to the user based upon which category the post they were reading was in. i.e., if the gravity form was embedded in a post in Category A, then we automatically display Confirmation Message A, if the form was embedded in a post in Category B, then we automatically display Confirmation Message B, etc.

    Any help would be greatly appreciated!

    Posted 12 years ago on Tuesday July 3, 2012 | Permalink
  2. Hi gravityfc,

    Paste this in your theme's functions.php file.

    http://pastie.org/4195261

    Now on the hidden field you'd like to populate the category for, add "post_category" as the dynamic population parameter: http://grab.by/exA0

    Now you can use the GF conditional shortcode to create different messages based on which category was submitted in this hidden field:

    http://www.gravityhelp.com/documentation/page/Shortcodes#Conditional_Shortcode

    Posted 12 years ago on Tuesday July 3, 2012 | Permalink
  3. gravityfc
    Member

    This worked perfectly. Thank you!

    Posted 12 years ago on Tuesday July 3, 2012 | Permalink

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