我在启用BuddyPress的WordPress网站上使用BuddyVerified。
验证图标不会出现在经过验证的用户配置文件的标题中,但是(可能是由于与主题有些不一致)。我尝试通过在网站的自定义Javascript框中输入以下代码,将验证图标附加到用户个人资料标题:
// Prepend to objects of class "user-nicename"...
$(".user-nicename").before(
// this PHP code
<?php
$ver_slug = basename(get_permalink());
$ver_user = get_user_by('slug', $slug);
$ver_user_id = $user->ID;
$ver_user_is_verified = bp_is_verified($user_id);
$ver_user_verified_icon = bp_verified_image($user_id);
?>
);
// Pass PHP boolean variable indicating user verification over to JS
var user_is_verified = <?php echo json_encode($ver_user_is_verified); ?>;
// If user is verified...
if (user_is_verified) {
// Prepend user verification icon to "user-nicename"
$(".user-nicename").before(
<?php echo $ver_user_verified_icon ?>
)
}
似乎合乎逻辑。虽然没有结果。 PHP不是我的强项。
谁能告诉我我做错了什么?