Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

eMember – prepopulate Gravity form fields with member details

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › eMember – prepopulate Gravity form fields with member details

Tagged: eMember, Gravity Forms, populate gravity form field

  • This topic has 9 replies, 4 voices, and was last updated 11 years ago by wzp.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • November 27, 2012 at 7:26 pm #8015
    igillanders
    Member

    Hello,

    I have been searching for several days now to figure out how I can get certain fields in my Gravity forms to be prepopulated with eMember member registration data. Basically, I need to have a few fields (name, email address, etc.) prepopulated from the member currently logged into eMember.

    I have already contacted Gravity Forms who provided me with some insights. Not being a programmer and not knowing PHP, I am struggling. I know that some PHP code needs to be inserted in the template’s functions.php file, but not exactly clear what.

    The guy at Gravity pointed me to a link explaining how their plugin handles dynamic population with hooks. http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population#Hooks

    I am really hoping (maybe dreaming!) that someone nice out there could give me some step-by-step instructions to make this happen. I am very familiar with both plugins, just need help with the coding. If this is too much to ask, I would be willing to pay a developer to do what I am sure is quite straight-forward.

    November 28, 2012 at 5:14 am #51826
    admin
    Keymaster

    Lets do a test with the email field first to see how we go. Please tell me the “parameter” name for the email field in your Gravity Form. I am referring to the following:

    http://grab.by/a79B

    It will allow me to give you a sample code to test.

    November 28, 2012 at 4:01 pm #51827
    igillanders
    Member

    Hi,

    Not sure what the parameter name should be. I imagine it could be anything, no? Is is not just a variable? If so, I guess I would call it “agent_email”.

    November 29, 2012 at 3:36 am #51828
    admin
    Keymaster

    Yes, I think that parameter name can be anything. So lets assume you are going to call that parameter “agent_email”. The code you need to add in your “functions.php” will be the following:

    add_filter('gform_field_value_agent_email', 'custom_population_function_for_agent_email');
    function custom_population_function_for_agent_email($value){
    if(wp_emember_is_member_logged_in()){
    $emember_auth = Emember_Auth::getInstance();
    $email = $emember_auth->getUserInfo('email');
    return $email;
    }
    }

    Let me know if that populates the email field with the members email.

    November 30, 2012 at 12:30 am #51829
    igillanders
    Member

    It worked beautifully! Now, if I want to populate multiple fields can you please give me the code? Would I simply replicate the entire above code once for each field?

    Here are the eMember fields and their corresponding parameter names:

    email


    > agent_email

    company—-> agent_company

    country—-> agent_country

    Thanks very much!!

    November 30, 2012 at 4:56 am #51830
    admin
    Keymaster

    Yes, you should simply replicate the above code for each field. Here is an example code:

    add_filter('gform_field_value_agent_country', 'custom_populate_agent_country');
    function custom_populate_agent_country($value){
    if(wp_emember_is_member_logged_in()){
    $emember_auth = Emember_Auth::getInstance();
    $country= $emember_auth->getUserInfo('country');
    return $country;
    }
    }

    add_filter('gform_field_value_agent_company', 'custom_populate_agent_company');
    function custom_populate_agent_company($value){
    if(wp_emember_is_member_logged_in()){
    $emember_auth = Emember_Auth::getInstance();
    $company_name= $emember_auth->getUserInfo('company_name');
    return $company_name;
    }
    }

    May 3, 2014 at 10:20 pm #51831
    Mcp
    Member

    Hi,

    I know that’s an old post but i didn’t want create a new one for my answer.

    First, thank you for this code this is just what i need.

    But can you give me the full list of variable name for the default eMember field like : name, phone, …

    It would help me a lot for prepopulate field in my GF forms.

    Thank you a lot.

    May 3, 2014 at 10:25 pm #51832
    wzp
    Moderator

    Is this what you really want?

    https://support.tipsandtricks-hq.com/forums/topic/how-to-retrieve-and-show-a-particular-info-of-the-logged-in-member

    May 3, 2014 at 10:42 pm #51833
    Mcp
    Member

    This is exactly what i really want.

    Big Thanks to you!

    May 3, 2014 at 10:44 pm #51834
    wzp
    Moderator

    8)

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ