Good question.. I did not know it was possible to display BP related info into blogposts? That could lead to many cool things like a “About me” widget on a user blog which displays info coming from their BP profile..
We were discussing displaying single xprofile fields here.
Someone gave me this function:
function custom_xprofile( $field ) {
echo bp_custom_get_member_list_xprofile_data( $field );
}
function bp_custom_get_member_list_xprofile_data( $field ) {
global $site_members_template;
return xprofile_get_field_data( $field, $site_members_template->member->id );
}
So you can use this in the members index.php:
<p><?php custom_xprofile('Company') ?></p>
But it only works in members_template. I’d like to have a function for xprofile fields that works anywhere…
Haven’t had time to try variations on this one. Suggestions very welcome!
@Anton Koekemoer, I’m pretty sure the key would be in replacing $site_members_template in the function, but I wouldn’t know with what.
EDIT2: Here’s the thread where I originally got the function, from John James Jacoby.
@Peterverkooijen.
I looked at that thread and was searching around to check if that’s possible. I’m sure I saw a thread somewhere where someone similar tried to do this with a custom xprofile Twitter profile field. Can’t find it now
Is it even possible to display “custom” xprofile fields in blog posts?
I’m answering the first post to this thread.
You can’t use an echo’d parameter (eg. the_author_id()), that is why your function isn’t displaying the xprofile field.
Parameters need to be returned, so use get_the_author_id() instead.
Example:
<?php echo xprofile_get_field_data( 'About me', get_the_author_id()) ?>
@r-a-y
Excellent! Thanks for that.
@r-a-y this helped me out so much… you have no idea. Thank you!
One more question, though, if you are available to help.
Is there a way to turn an xprofile field into a tag? I’m trying to track posts by country so we could then click on the country and see all the posts from that country. (I have a drop down of all countries as a required registration field.)
Or is there a better way to go about it? I don’t mind learning/doing work, I just have no idea how to go about it. Any ideas?
Thanks and best wishes,
Kristen