BuddyDev

Search

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: 24212
    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.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 1
    Afshin on #47814

    I am sorry, I am a bit new to this, where is this code to be added?

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #47817

    Hi Afshin,
    You can put the code in your child theme’s functions.php
    Or if you are using any php code snippet plugin, you can add it to that.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 1
    Jean-Luc Scherer on #50789

    I tried this and it doesn’t seem to work. I am able to extra fields in the profile but not in the members card. Is this the right hook? Or should i try something else

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #50791

    Hello,

    Please try to switch to the default theme and check whether the profile data is showing.

    Note: Please ensure you have updated the field name in the code as per your field name.

    Regards
    Ravi

The topic ‘Displaying BuddyDev Xprofile custom fields on BuddyBoss Member Card’ is closed to new replies.

This topic is: not resolved