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 Populate Fields

  1. Can you pre populate fields based on a logged in user... Say you have a support form so based on the user that is logged into your site.. The name and email field would be pre populated based on the user that is logged in to wordpress??

    Thanks Scott

    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  2. Yes. There are two ways to do this. If it's information on the user that is logged into the site you may be able to simply use available merge tags and the default value option on fields it's available for.

    Merge tags are documented here:

    http://www.gravityhelp.com/documentation/page/Merge_Tags

    So if you want to populate the email field with the email of the user that is logged in and filling out your form, you would:

    - Edit the email field on your form
    - Select the advanced tab
    - In the default value set it to {user:user_email}
    - Save your form

    Now that field's default value will be set to the email of the user viewing the form if they are logged in.

    If it's information that can't be output via available merge tags then you can always use some custom PHP and dynamically populate the field. Here is some information on how to dynamically populate fields:

    http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population

    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  3. Ah .. cool.. I see that for email but not name... Name has a different option... (allow field to be populated dynamcially via short code query string or hooks.... is the name not as easy?

    I tried adding this in the name field {user:user_login}
    The email field is working :) Awesome... supplies a drop down to select from but not the name fields :(

    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  4. raffav
    Member

    i tried with {user:first_name} in the advanced name field and nothing happen, but if i use a simple line text field it's ok all work fine;

    Posted 12 years ago on Thursday November 24, 2011 | Permalink
  5. I have the same problem; is it possible to populate the advanced name field from the WordPress user data?

    Posted 12 years ago on Thursday December 8, 2011 | Permalink
  6. You'd have to know what the user meta key name is for the the user meta you want to display using the merge tag. It's {user:key} and the key is the user meta key name for the data you want to return.

    Posted 12 years ago on Thursday December 8, 2011 | Permalink
  7. Hi guys,

    Here is a more advanced solution that allows you to use Gravity Forms dynamic population to populate any user meta in any field that support dynamic population:

    http://www.gravityhelp.com/forums/topic/right-parameter-names-to-pre-populate-the-names-fields#post-14044

    Posted 12 years ago on Thursday December 8, 2011 | Permalink
  8. gchinola
    Member

    I'm having the same issue as raffav. I added the name field and set it so it's first name/last name. Checked the box in the advanced tab for allowing the field to be populated dynamically. I added {user:first_name} in the first name and {user:last_name} in last name from what I found here:
    http://www.gravityhelp.com/documentation/page/Merge_Tags

    It's displaying the email address correctly for a logged in user but the name fields are blank.

    Just for the heck of it I replaced the first name meta key with {user:user_email} and the first name field is still blank when a logged in user looks at the form.

    Posted 12 years ago on Wednesday December 14, 2011 | Permalink
  9. Hi gchinola,

    The more advanced method does not user Merge Tags to populate; it is powered by the custom snippet provided in the thread I linked to. After implementing the snippet, you're dynamic population parameters should look like this:

    http://grab.by/8qjd

    Posted 12 years ago on Wednesday December 14, 2011 | Permalink
  10. gchinola
    Member

    I was trying the non-advanced method which I think is supposed to work. If it's not working, I'll give the advanced method a shot, I just didn't think I needed to.

    Posted 12 years ago on Wednesday December 14, 2011 | Permalink
  11. I understanding the confusion. A couple things to keep in mind. The "Enable Dynamic Population" option does not support merge tags. The "Default Value" option supports some merge tags. You'll notice that on some field types (including the "Name" field), there is no option to specify a default value. This means in order to populate a default value you'll need to use dynamic population.

    The advanced method I linked to uses dynamic population to populate the user meta based on your dynamic population parameters and a little configuration in the code. Don't be daunted by it! It's easier than you think. :)

    Posted 12 years ago on Thursday December 15, 2011 | Permalink
  12. Hey, I think the users here are trying to point out a recent bug.

    Merge tags such as {user:first_name} USED TO work just fine as a default value, but they are not working any more. This is a semi-recent phenomenon. It has broken a number of my forms that were working just fine before.

    Posted 12 years ago on Saturday December 31, 2011 | Permalink
  13. Estone
    Member

    Ended up here trying to pre populate some formfields. Could not get it to work.
    Now I read mr. g0shu4 message, here above!

    Could it be that something changed and the code is not working anymore?
    I am on Wordpress 3.3.1 (most recent as of now).

    Can someone please confirm this. And is there a workarround??

    Posted 12 years ago on Thursday January 12, 2012 | Permalink
  14. storklawyer
    Member

    Until recently, {user:display_name} and {user:user_login} were working anywhere I put them in the form and notification area. I thought it was user error in forms that are already live.

    I'm building a new form today and notice now they are not working at all.

    Posted 12 years ago on Friday January 13, 2012 | Permalink
  15. storklawyer
    Member

    Oh, and I'm using WP 3.3.1 and GF 1.6.2

    Posted 12 years ago on Friday January 13, 2012 | Permalink
  16. Estone
    Member

    Better continue this over here:
    http://www.gravityhelp.com/forums/topic/bug-report-pre-populate-not-working

    Posted 12 years ago on Friday January 13, 2012 | Permalink
  17. We have a fix for the user merge tags no longer pre-populating the fields. This appears to have happened with WP 3.3. Because we have a lot of new features coded for Gravity Forms version 1.6.3, we are providing this fix as version 1.6.2.1.1 and those who need it should email me directly at the email address on my user profile and mention this topic. I will email you the file.

    Thanks!

    Posted 12 years ago on Friday January 13, 2012 | Permalink
  18. I am closing this ticket. Please use http://www.gravityhelp.com/forums/topic/bug-report-pre-populate-not-working instead for issues with this discovered bug.

    Posted 12 years ago on Friday January 13, 2012 | Permalink

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