Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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;
?>
share|improve this question

closed as off-topic by Pieter Goosen, toscho Jul 18 at 6:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

After playing around with it a bit more, here's what finally worked for me:

global $bp;
$thisblog = $current_blog->blog_id;
$user_from_email = get_user_by('email', get_blog_option($thisblog, 'admin_email'));
$user_id = $user_from_email->ID;
$myfield = xprofile_get_field_data( 'Counties Served', $user_id, $multi_format = 'comma' );
$data = xprofile_format_profile_field('checkbox', $myfield);
echo $data;
share|improve this answer

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.

<?php 
global $bp, $post;
$myfield = xprofile_get_field_data( 'Counties Served', $post->post_author, $multi_format = 'comma' );
$data = xprofile_format_profile_field('checkbox', $myfield);
echo $data;
?>
share|improve this answer
    
Thanks @modemlooper. For some reason your solution didn't work for me - not sure why but it was pulling the super admin's ID instead. Nevertheless, this put me on the right track. I'll post what worked below. –  pollyplummer Apr 24 '13 at 23:01
    
I just wrote that off top of my head, glad you found something to work. –  modemlooper Apr 24 '13 at 23:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.