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.

passing conditional user meta

  1. I have a registration form where upon selecting a Country from a drop down menu uses conditional logic to display either a state drop menu, a province drop menu or a state/province/region text field.

    I have set up a single custom user meta field called "state". I'd like to enter the value of either the state drop menu, the province drop menu or the state/province/region text field (depending which is appropriate).

    I don't see how to do this using the built in user meta options in the User Registration add-on.

    Is there a way to accomplish this?

    Posted 7 years ago on Monday October 15, 2012 | Permalink
  2. You want to populate the form with the value from the meta field, or you want to populate the meta field with the value entered into the form? I'm not clear what you're trying to do. However, since this is a registration form, it sounds like you want to store the state/province or region in the user's profile as a meta key?

    Posted 7 years ago on Monday October 15, 2012 | Permalink
  3. Hi Chris,

    I'd like to store the state/province or region as a meta key.

    Posted 7 years ago on Monday October 15, 2012 | Permalink
  4. On the User Registration settings for the feed, can you map the drop down to a custom field? Screenshot: http://minus.com/lFgCcC9egJ8lJ

    Or, is the problem you want to store either the region, province or state, in the same meta key, no matter which one it is? Or are you having some other problem saving that value to a meta key in the user profile?

    Posted 7 years ago on Monday October 15, 2012 | Permalink
  5. you've described the problem, exactly. I'd like to store things in the same meta key.

    Posted 7 years ago on Monday October 15, 2012 | Permalink
  6. It may not be possible to do that. Can you map state to one key, province to another and region to another, then test in the profile which one is populated, and display that? I don't think you can combine conditional logic and mapping the usermeta like that.

    You could instead update the usermeta after form submission using the gform_user_registered filter.

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

    The example shows updating the usermeta.

    Posted 7 years ago on Tuesday October 16, 2012 | Permalink
  7. The client only wants one key in the user profile.

    Would there be some way to write a pre-submission hook which checks which conditional field has been populated and pass that?

    Or maybe pass the results of the conditional fields into a new hidden field and use that to populate the meta key?

    Posted 7 years ago on Tuesday October 16, 2012 | Permalink
  8. You could update the one meta key after form submission using gform_user_registered. Do not map the field in the user registration feed. Then, in the code which runs attached to gform_user_registered, you can test for which selection was made in your form, and store the correct value.

    Posted 7 years ago on Wednesday October 17, 2012 | Permalink
  9. That sounds promising Chris. Would you have an example of such a function?

    Thanks.

    Posted 7 years ago on Wednesday October 17, 2012 | Permalink
  10. The example code on this page is good:
    http://www.gravityhelp.com/documentation/page/Gform_user_registered

    Instead of just the single line to update usermeta, you will have a function to see which field in your entry was filled in, then update the single key with any one of those three types of value. What I would do is dump the $entry array with print_r($entry); and see there the values show up in your form submission. Then, it will be a matter of determining which one is set, and updating the usermeta as shown in the example code. There are only a couple more lines you will need to add to the example. If you get stuck, share a print_r of the entry (post it at pastebin.com or pastie.org because it will be huge.) You should submit the form with each of the three types of inputs being used, so you know exactly how each will show up in your entry.

    Posted 7 years ago on Thursday October 18, 2012 | Permalink
  11. Formmaker
    Member

    i am trying to grab a vlue from a dropdown choice that is only on the form and prepopulate the notification message with it

    {Current Academy and Team:60} is the field code i used for the drop downmenu, but there are many selections (100), and when i pick one it gives me a different result in the notification form mailed out

    menu is set usps as field -= school value = team
    problem people are picking based on school and wrong school is showing up omn their notification

    concenred this is a bug unless i just need to up date my syntax

    Posted 7 years ago on Tuesday October 30, 2012 | Permalink
  12. @Formmaker, please begin a new topic with your question as it is completely unrelated to this topic here. I'll delete your reply here after you have created a new topic.

    Posted 7 years ago on Wednesday October 31, 2012 | Permalink
  13. Formmaker
    Member

    i posted it here because it thought it completely related

    -proper syntax for grabbing values from a drop down menu - seemed similar to original question,
    -and i also have field and value concerns much like previous poster,
    -i too want to use user meta if possible properly and I too want to pre-populate....
    -the only difference - which should simplify - is conditional aspect - which i am not sure i need but could need it.

    i tried setting this up and when the user grabbed a drop down menu item they seemed to be getting another value for a response.... this seems confusing - poster starts a thread with a topic, you search for something similar and find it as related to your concern...poster and support evolve the topic, you post regarding similarity to first posts....but asked to start a new thread.

    5 days

    square one.
    ok
    i will repost i guess, it is just unfortuenate that it will be separated from something so related - part of the problem i am having is getting too many relevant responses for the same issue or topic...

    Posted 7 years ago on Monday November 5, 2012 | Permalink
  14. @Formmaker, please do begin a new topic so we can address your situation with individual attention. Thank you.

    Posted 7 years ago on Monday November 5, 2012 | Permalink

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