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.

Dynamically populating BuddyPress Profile fields

  1. I am trying to pre-populate a form with a few BuddyPress fields using the add_filter function.

    http://pastebin.com/i0nUxaEg

    I can return the value fine on a page, but can not have it populate the GravityForm. Allow field to be populated dynamically is checked and parameter is populate_hotel.

    Am I missing something?

    Posted 10 years ago on Monday May 27, 2013 | Permalink
  2. David Peralty

    Parameter should be ambassador_hotel.

    Posted 10 years ago on Monday May 27, 2013 | Permalink
  3. Thanks for the quick reply David. I've tried that and it still does not populate. Any other ideas?

    Posted 10 years ago on Monday May 27, 2013 | Permalink
  4. David Peralty

    Can you force $ambassadorhotel to have a value, say "Test" and see if it populates properly? If so, then maybe there isn't a value being passed to that variable from your BP code. If it doesn't work, then something is configured wrong, and we'd have to figure out what.

    Posted 10 years ago on Monday May 27, 2013 | Permalink
  5. @tatertot did you make it work? , I have the same problem pre populate buddypress profile fields and your code doesn't work for me too:

    //Buddypress prepolute 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;
        }
    Posted 10 years ago on Wednesday July 10, 2013 | Permalink
  6. David Peralty

    Daniel, can you try what I asked tatertot to do please and see what happens?

    Posted 10 years ago on Wednesday July 10, 2013 | Permalink
  7. Dave I would love to do that, but honestly my PHP knowledge is very bad so I don't know exactly how: "...to force a phone to have a value "test" (the code). Can you help me to give me that code and I will immediately try it?

    Posted 10 years ago on Wednesday July 10, 2013 | Permalink
  8. David Peralty

    Assuming you have the parameter of the field set to phone, then you should be able to swap out:

    $phone = bp_profile_field_data( array('user_id'=>$current_user_id,'field'=>'phone' ));

    for

    $phone = "(555) 555-0123";
    Posted 10 years ago on Wednesday July 10, 2013 | Permalink
  9. David, thank you very much for your help, your snippet I will use for my future issues, I got that working with another BP code now:

    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);
    }

    This code with "xprofile_get_field_data" and parameter= city works, now I will also search for drop down solution, thanks again and you can mark as "RESOLVED" this thread.

    Posted 10 years ago on Wednesday July 10, 2013 | Permalink

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