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.

Populating a hidden field

  1. Hi,

    I saw that in the new version you can pass hidden fields, I was wondering how I would go about passing the post id in this field?

    Also, another problem that I'm having is I want to have a form made up of custom fields which will form posts in my blog. I want users to be able to submit custom fields, and I see the option of "custom field name" where you can choose existing or new. When I choose existing, I dont get any to choose from. I have 9 custom fields so I would expect to see those there. What am I doing wrong?

    Thanks,
    Steph

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  2. - Add a hidden field to your form
    - Edit the hidden field
    - Select the advanced tab

    On the advanced tab you will see the Default Value field. Above that is the insert variable drop down. From this variable drop down you can select the Embed Post/Page Id. This will insert the variable for this into the default value field.

    Save your form. Test it out.

    When the form is submitted this hidden field will be populated with the post id of the post/page it was submitted on.

    You will also notice other variables in this drop down. There are a variety of variables you can use to dynamically populate hidden (and non-hidden) fields without having to write any code.

    Optionally you can also populate fields by writing custom PHP.

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  3. Forgot to mention, the URL of the page/post the form is submitted on is already stored with the entry and available as a notification variable. When viewing an entry in WordPress, on the right side of the screen you will see the Embed URL. This is the URL of the page/post the form was submitted on.

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  4. Thanks for your replies. I think I'll need to create custom php as I want to have the form on a different page to the posts. (a "report a problem" link that takes them to a form which has a form for them to complete to tell me what's wrong).

    I edited the post (I think while you were replying to add in another problem) are you able to help with that issue too please?

    Thank you.
    Steph

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  5. You mention that you have 9 custom fields, do these custom fields already have data populated in them or are they just present in your theme? In order for the existing custom fields to show up in the drop down they need to already have posts created with them that have values for these custom fields.

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  6. BTW one of the variables you can use as the default value in a hidden field is the HTTP Referrer URL.

    This would be the URL of the page the user came from... which would be the post they were having problems with if they clicked a link to the form.

    Now this wouldn't be the post id, but it would be the full URL to the page.

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  7. Hi,

    Of the custom fields at least 7 of them are populated throughout all the entries yeah. Do I need to do anything special for them to show up in the list?

    Thanks for the tip re using the HTTP referrer URL - that will work perfectly. Thanks for that.

    Steph

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  8. It's hard to tell if something is going on. I would need a login to this site in order to take a look. If you want me to take a look then use the Contact Us form and send me a WordPress login to this site and i'd be glad to look into it.

    Posted 14 years ago on Tuesday January 12, 2010 | Permalink
  9. I have no idea why, but it's now working and showing me a list of custom fields!

    Thanks for the offer of help.

    Steph

    Posted 14 years ago on Saturday January 16, 2010 | Permalink