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.
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- This reply was modified 2 years, 11 months ago by Brajesh Singh.
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
BrajeshI 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
The topic ‘Displaying BuddyDev Xprofile custom fields on BuddyBoss Member Card’ is closed to new replies.