BuddyDev

Search

[Resolved] Showing Specific Fields from BuddyPress Profile Data on Members Directory

  • Participant
    Level: Enlightened
    Posts: 23
    James Moss on #35549

    Hi Brajesh,

    Hope you’re well.

    We’re trying to set up a tutoring website (based on BuddyPress), and would like to display the tutors with specific fields from their profile data, on members directory page.

    Please could you kindly suggest, how could we possibly implement this?

    Please also see the screenshot for illustration:
    https://prnt.sc/wyb0kn

    Kind regards,
    James

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #35554

    Hi James,
    Thank you.

    I hope you are doing well too.

    You can use xprofile_get_field_data to fetch and show the field.

    Which template pack are you using? Please let me know and I or Ravi will assist you with the code.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 23
    James Moss on #35561

    Hi Brajesh,

    Thanks for your reply. We’re using BuddyBoss.

    Kind regards,
    James

  • Participant
    Level: Enlightened
    Posts: 23
    James Moss on #35562

    Currently, the members directory displays like this – without profile fields.

    https://prnt.sc/x2luc7

    Best,
    James

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

    Hello James,

    Please try the following code to render extra member data on member’s directory page.

    
    
    /**
     * Add extra fields data on member directory page.
     */
    function buddydev_render_extra_fields_data() {
    
    	if ( ! bp_is_active( 'xprofile' ) ) {
    		return;
    	}
    
    	$member_id = bp_get_member_user_id();
    
    	// Replace by your fields.
    	$city_field_id = 2;
    
    	$city = xprofile_get_field_data( $city_field_id, $member_id, 'comma' );
    	$city = $city ? __( 'City: ' ) . $city : '';
    
    	echo esc_html( $city );
    }
    
    add_action( 'bp_directory_members_item', 'buddydev_render_extra_fields_data' );
    
    

    PLease let me know if you need furthur assistance.

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 23
    James Moss on #35619

    Hi Ravi,

    Thank you so much, I’ll let you know if it worked.

    Kind regards,
    James

  • Participant
    Level: Enlightened
    Posts: 23
    James Moss on #35664

    Hi Ravi,

    It didn’t work.

    The extra fields that we’d like to display on members directory, come from ‘extended profile’ field sets (already created using BuddyBoss Platform).

    But I still created an extra country field using xprofile, in order to test your code but didn’t work either.

    We don’t actually need ‘Xprofile Custom Field Types’ because we have all the field sets we need (BuddyBoss default). Is your code only meant to work with ‘Xprofile Custom Field Types’ plugin?

    Kind regards,
    James

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

    Hello James,

    Thank you for the acknowledgement. I have checked this on my server and it showing city field on directory page. Please take a look here:

    https://tinyurl.com/y39becvk

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 23
    James Moss on #35683

    Hi Ravi,

    Many thanks, I’m trying to figure out why it’s not working for me.

    Just repeating my earlier question above for clarity:

    We don’t actually need ‘Xprofile Custom Field Types’ because we have all the field sets we need (BuddyBoss default). Is your code only meant to work with ‘Xprofile Custom Field Types’ plugin?

    Kind regards,
    James

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #35684

    Hi James,
    No, you do not need the xprofile custom profile field type plugin. The above code is a core BuddyPress/BuddyBoss function.

    You may want to check for the field id and update it.

    Regards
    Brajesh

The topic ‘ [Resolved] Showing Specific Fields from BuddyPress Profile Data on Members Directory’ is closed to new replies.

This topic is: resolved