显示好友按配置文件字段


Display Buddypress Profile Field

使用最新版本的Wordpress和Buddypress,我正在尝试在WP标题.php中显示某个自定义配置文件字段。我对PHP很糟糕,但这就是我所拥有的:

<?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=""/>';
}
?>

我不太清楚为什么它不起作用。源显示变量仍在 URL 中。

另外,我认为我不需要$user_user_id变量,因为它并没有真正被使用,对吗?我正在按照本主题中的说明进行操作:http://buddypress.org/support/topic/how-to-get-user-profile-data/

尝试:

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

请注意单引号与双引号的使用。