Skip to:
Content
Pages
Categories
Search
Top
Bottom

Use BP data to populate per-user forms

  • Avatar of evrenk
    evrenk
    Participant

    @evrenk

    Hello,

    We have a bunch of profile fields and custom fields of data about our members. On a one by one basis and with people’s explicit approval, we would like to export this data to an external registration system using POST through a pre-populated form. We use BP 1.7 and WP 3.5.2.

    We struggle to generate and populate the form with the right values from the logged-in user’s profile. Trying to use xprofile_get_field_data doesn’t yield any result at all which is strange, it maybe because we don’t have the right keys.
    It returns null or an empty string no matter how we try to use it.

    – Did any of you ever try to do something similar and how?
    – Does it have to be used in some kind of loop?
    – Where can I find the right keys for the fields?

    Kind regards,
    Evren

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of 4ella
    4ella
    Participant

    @4ella

    I am trying something similar with gravity forms, I am trying to pre-populate gravity forms fields with buddypress profile data fields and I can’t get it work too, I am using something like this in functions.php if it helps:

    // Buddypress pre-populate phone
        add_filter("form_field_value_phone", "populate_phone");
        function populate_phone() {
                $current_user = wp_get_current_user();
                $current_user_id = $current_user->ID;
                $phone = bp_profile_field_data( array('user_id'=>$current_user_id,'field'=>'phone' ));
                return $phone;
        }
    Avatar of 4ella
    4ella
    Participant

    @4ella

    If somebody need it, I got that working with gravity forms using this code, gravity forms parameter name= city

    add_filter("gform_field_value_city", "populate_city");
    function populate_city($value){
         global $current_user;
         get_currentuserinfo();
         return xprofile_get_field_data('city', $current_user->ID);
    }
    Avatar of evrenk
    evrenk
    Participant

    @evrenk

    Hello,

    We’ll investigate these code snippets. Others, feel free to join the discussion and add yours. It will greatly help us and other people who might try to do the same thing.

    Thanks in advance,
    Evren

    Avatar of 4ella
    4ella
    Participant

    @4ella

    @evrenk That snippet works with gravity forms text field, I already know that it doesn’t work with dropdown fields, I didn’t test it with other fields as radio etc buttons, I will also try to find a solution for dropdown fields and if I will find it I will report it here.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.