Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] xprofile fields outside of profile / buddypress

  • @chriswinch

    Participant

    Hey,
    I have managed to get my custom user fields / xprofile fields to show but only when im on the profile page. I tried the groups page but they don’t seem to be showing.

    What im trying to do is pull the xprofile fields into the header so that they show site wide.
    Is this possible?

    The code im using is:
    bp-custom.php

    
    <?php 
    function custom_xprofile( $field ) {
    echo bp_custom_get_member_list_xprofile_data( $field );
    }
    
    function bp_custom_get_member_list_xprofile_data( $field ) {
    global $site_members_template;
    return xprofile_get_field_data( $field, $site_members_template->member->id );
    }
    ?>
    

    Template

    
    <?php custom_xprofile('First Name') ?>
    

    I found the above code on this forum, but dont remember what post i found it in.
    Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @modemlooper

    Moderator

    $user_id = get this from WordPress;
    xprofile_get_field_data( $field, $user_id );

    The way you are getting members id is only good on member pages. If you are on a blog post you can get the author id, if you want logged in user id get that.

    @chriswinch

    Participant

    Thanks for your help.
    Managed to get it working by using the wordpress user id as you mentioned.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] xprofile fields outside of profile / buddypress’ is closed to new replies.
Skip to toolbar