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.

Help with User add On

  1. sadiq.emeran
    Member

    Step 1
    http://communipet.co.za/register/
    user registers on site fills out form.
    Step 2
    http://communipet.co.za/add-pets/

    User adds pets but 1st part is dynamically populated as it is filled in at registration.

    Any help

    Please

    I can get name and email working but not other fields.

    Thanks
    Sadiq

    Posted 11 years ago on Monday October 29, 2012 | Permalink
  2. sadiq.emeran
    Member

    [php]
    // populate the field with "user_firstname" as the population parameter with the "first_name" of the current user
    add_filter('gform_field_value_user_firstname', create_function("", '$value = populate_usermeta(\'first_name\'); return $value;' ));
    
    // populate the field with "user_lastname" as the population parameter with the "last_name" of the current user
    add_filter('gform_field_value_user_lastname', create_function("", '$value = populate_usermeta(\'last_name\'); return $value;' ));
    
    // populate the field with "user_id" as the population parameter with the "id_number" of the current user
    add_filter('gform_field_value_user_id_number', create_function("", '$value = populate_usermeta(\'id_number\'); return $value;' ));
    
    add_filter('gform_field_value_user_email', create_function("", '$value = populate_usermeta(\'email\'); return $value;' ));
    
    // this function is called by both filters and returns the requested user meta of the current user
    function populate_usermeta($meta_key){
        global $current_user;
        return $current_user->__get($meta_key);
    }

    Above is the code I used.

    Posted 11 years ago on Tuesday October 30, 2012 | Permalink
  3. Are you trying to populate usermeta fields in form 2? If the user is logged in when they visit form 2, all the meta values should be available as merge tags without using any code. I'm not following the process you're using here. Can you please explain more about it? Thank you.

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink