Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Members loop and custom profile fields

  • Ok I know i can echo out each indiviual custom field inside the members loop like so:

    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : 
           		echo bp_member_profile_data('field=Gender');
           		
    ?>
     <?php endwhile; ?>

    but how do i go about accessing the whole object or array on a per user basis is there a function for this?
    I’ve tried get_user_meta(); but no luck it looks like buddypress doesn’t store it’s profile field data there, which is where i would have thought it was kept….
    I could use $wpdb but it seems a little overkill.
    Any advice is appreciated
    Chris

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

  • shanebp
    Moderator

    @shanebp

    Are you concerned about multiple calls to bp_member_profile_data() ?

    When used in the members loop, all profile data is cached.
    See function bp_get_member_profile_data() in
    bp-members/ -> bp-members-template.php

    You can also use :
    $profile_data = BP_XProfile_ProfileData::get_all_for_user( $user_id );
    See the class in bp-xprofile/ -> bp-xprofile-classes.php

    But that is called in bp_member_profile_data(), so afaik there is no advantage to that approach in terms of db calls.

    Perfect that is exactly what i was looking for!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Members loop and custom profile fields’ is closed to new replies.
Skip to toolbar