Displaying BuddyDev Xprofile custom fields on BuddyBoss Member Card

  • Participant
    Level: Initiated
    Posts: 9
    Mark Haygen on #42679

    I would like to display a couple BuddyDev xProfile custom fields on the member’s search result card in my BuddyBoss Theme and Platform based community site.

    I would like to add a couple fields that I created using BuddyDev xProfile Custom Fields Plugin on the BuddyBoss Directory Member Card. I am not sure what they call it but it is the directory results after a search has been processed.

    Example: As of right now the card displays a profile pic, User Nickname, and profile Type.

    I would like it to display profile pic, Nickname, *Primary Job Title, * City, State.
    *=XProfile Custom Field.

    BuddyBoss says I need to speak with someone at BuddyDev to learn how to display the fields and right the code.
    I hope BuddyDev does NOT tell me that BuddyBoss has the answer.

    I would appreciate any and all assistance.

  • Participant
    Level: Initiated
    Posts: 9
    Mark Haygen on #42680

    Write the code not “Right”

  • Keymaster
    (BuddyDev Team)
    Posts: 21785
    Brajesh Singh on #42698

    Hi Mark,
    Thank you for the question.

    I am sorry to hear about this. BuddyBoss support is misguiding you If they said that you need to contact us for this. There is no difference between core xprofile fields and custom field types added by us when you are fetching the data.

    Irrespective of how a profile field was added, you can access the data using xprofile_get_field_data(“Filed Name or ID”, $user_id). That will give you the data stored for that user in that specific field.

    Here is a code sample that works for BuddyPress.

    add_action( 'bp_directory_members_item', function() {
    	$user_id = bp_get_member_user_id();
    	echo "About the user: ". xprofile_get_field_data("About", $user_id );
    	echo "Field 2 value:". xprofile_get_field_data("Field 2", $user_id );

    You will need to update this with your field names instead of About abd “Field 2”. I haven’t tested this snippet with BuddyBoss theme. Please give it a try and see if it works with their theme or not.
    If not, you will need them to ask which hook to use instead of “bp_directory_members_item”. Rest of the code will remain same.

    Hope that helps.


You must be logged in to reply to this topic.

This topic is: not resolved