Display Buddypress Profile Field

Using the latest version of WordPress & Buddypress, I am trying to display a certain custom profile field in the WP header.php. I’m terrible with PHP, but this is what I have:

<?php
global $bp;
$the_user_id = $bp->loggedin_user->userdata->ID;
if (function_exists('bp_get_profile_field_data')) {
    $bp_gamertag = bp_get_profile_field_data('field=Gamertag&user_id='.bp_loggedin_user_id());
    if ($bp_gamertag) {
        echo '<img src="http://avatar.xboxlive.com/avatar/$bp_gamertag/avatar-body.png" alt=""/>';
    }
    else
        echo '<img src="http://avatar.xboxlive.com/avatar/xbox/avatar-body.png" alt=""/>';
}
?>

I can’t quite figure out why it isn’t working. The source shows the variable still in the URL.

Read More

Also, I don’t think I need the $user_user_id variable, as it isn’t really being used, do I? I’m following the instructions in this topic: http://buddypress.org/support/topic/how-to-get-user-profile-data/

Related posts

Leave a Reply

1 comment

  1. Try :

     echo "<img src='http://avatar.xboxlive.com/avatar/$bp_gamertag/avatar-body.png' alt='' />";
    

    Notice the use of single vs. double quotes.