I’m trying to display a BuddyPress xprofile field on a WordPress multsite blog. I thought this might do the trick but displayed_user doesn’t seem to work outside of BP? Is there an easy way to do this? I know there’s an old plugin that does it in a widget but I don’t really need all of that and would rather put this directly in the theme.
Here’s what I’ve tried within the theme on the multisite blog. This works with loggedin_user->id but of course what I’m shooting for is the profile data for the blog admin. Is that possible to fetch?
<?php
global $bp;
$myfield = xprofile_get_field_data( 'Counties Served', $bp->displayed_user->id, $multi_format = 'comma' );
$data = xprofile_format_profile_field('checkbox', $myfield);
echo $data;
?>
After playing around with it a bit more, here’s what finally worked for me:
The
$bp->displayed_user->id
returns the same id as the author id so when you are not inside a members loop or on a members page you have to get the user id using WordPress functions.