Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to grab xprofile data?

  • @sameast

    Participant

    Hi

    I looking to change the structure off buddypress so the when you search for a member instead of just the member avatar and name and activity listed i would like to list some extra information from each members profiles.

    (this page) http://buddy.users32.interdns.co.uk/members/

    I have downloaded all the file and see that this section is in the members-loop.php. I can delete parts of this but as far as adding sections from the members profile im not sure how to do this as the profile fields are in the profile-loop.

    Any ideas on how to merge these together, bad in need off help in this.

    Thanks

Viewing 13 replies - 1 through 13 (of 13 total)
  • @boonebgorges

    Keymaster

    If you want to get information out of the custom xprofile fields, you’ll need to use some of the functions in the profile-loop. I don’t think there are any core BP functions that allow you to pull a specific profile field by name or ID, so you’ll have to create a profile loop (<?php if ( bp_has_profile() ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>), then a profile field loop (<?php if( bp_profile_group_has_fields() : while ( bp_profile_fields() ) : bp_the_profile_field(); ?>) and then loop through the items, picking out the ones you want by field name. Use the code in profile-loop.php as a template for what you want to insert into members-loop.

    @r-a-y

    Keymaster

    Boone is right; however there is a way to post specific xprofile fields!

    Check out a nifty function called bp_profile_field_data().

    Say I have an xprofile field called “Bio”.

    I’d use this code snippet:

    bp_profile_field_data('field=Bio');

    This will echo the “Bio” xprofile field of the displayed user.

    If you want to manipulate the data, use:

    bp_get_profile_field_data('field=Bio');

    @boonebgorges

    Keymaster

    Oho, I learn something new every day!

    So r-a-y – since it’s profile-field specific, you can probably skip while (bp_profile_fields() ) : bp_the_profile_field() right? #toolazytotrymyself

    @r-a-y

    Keymaster

    Yes you can skip the while loop!

    @sameast

    Participant

    Hi guys i couldn’t get it to show information about the profiles on the member-loop.php with

    bp_profile_field_data('field=Bio');

    but i managed to get it to work with this one

    bp_member_profile_data('field=Postcode');

    Hope this help someone thanks guys

    @blogadera

    Participant

    nm on our note. was completely the long and wrong way. can accomplish with css and using the function mentioned. it already hides if empty…der

    @blogadera

    Participant

    wonder if the same would work for a profile field group?

    @gaysurfers

    Participant

    Hi r-a-y

    I have tried to post specific xprofile fields with no success.
    It did work but since I installed the new version of buddypress (Version 1.2.2.1) it seems to have stopped working.
    http://www.gaysurfers.net/members/

    I have tried the following:

    <div class="item-meta"><?php bp_profile_field_data( 'field=Country' ) ?> - <?php bp_profile_field_data( 'field=Surf Spot' ) ?></div>
    
    and also
    
    <div class="item-meta"><?php bp_member_profile_data( 'field=Country' ) ?> - <?php bp_member_profile_data( 'field=Surf Spot' ) ?></div>

    I don’t know which one to use, but anyway none of them works. Is there some more code I need to add for it to work?
    Thanks

    @apeatling

    Keymaster

    Try

    <?php bp_profile_field_data( 'field=Country&user_id=' . bp_get_member_user_id() ) ?>

    @gaysurfers

    Participant

    YEAH!!! It’s working!!

    Tx Andy!

    @chiinook

    Participant

    Hey Gents … picking up on the question posed by @blgdra here, is there a conditional statement I can use to show the field only when it is populated, or even only when populated with a given value?

    I have
    `Field Title: `
    and would like to hide the Field title as well as the value when there is no value.

    @hnla

    Participant

    Try:
    if (bp_get_profile_field_data('field=thefield'))
    or
    if (bp_get_profile_field_data('field=thefield') == 'string')

    @timersys

    Participant

    Hi Guys im trying to do the same on a custom wordpress page but it seems that
    if ( bp_has_profile() ) always returns false and i dont know why.
    I even tried to put this on my custom page.

    I need to load any file or globalize a variable?
    I just need to make this work inside a custom page within wordpress.
    Thanks for all the help

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to grab xprofile data?’ is closed to new replies.
Skip to toolbar