Tagged: Members Directory
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/wyb0knKind regards,
JamesHi 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
BrajeshHi Brajesh,
Thanks for your reply. We’re using BuddyBoss.
Kind regards,
JamesCurrently, the members directory displays like this – without profile fields.
Best,
JamesHello 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
RaviHi Ravi,
Thank you so much, I’ll let you know if it worked.
Kind regards,
JamesHi 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,
JamesHello 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:
Regards
RaviHi 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,
JamesHi 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.